解决ScrollView嵌套ListView和GridView冲突的方法
2015-08-02 15:51
375 查看
文章出处:/article/9641920.html
public class MyListView extends ListView { public MyListView(Context context) { super(context); } public MyListView(Context context, AttributeSet attrs) { super(context, attrs); } public MyListView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec); } } public class MyGridView extends GridView { private boolean haveScrollbar = true; public MyGridView(Context context) { super(context); } public MyGridView(Context context, AttributeSet attrs) { super(context, attrs); } public MyGridView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } /** * 设置是否有ScrollBar,当要在ScollView中显示时,应当设置为false。 默认为 true * * @param haveScrollbars */ public void setHaveScrollbar(boolean haveScrollbar) { this.haveScrollbar = haveScrollbar; } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { if (haveScrollbars == false) { int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec); } else { super.onMeasure(widthMeasureSpec, heightMeasureSpec); } } }
相关文章推荐
- AngularJS
- JS中的继承链
- Using RUNDLL32.exe to call a function within a dll
- 应用程序添加角标和tabBar添加角标,以及后台运行时显示
- PXE/Kickstart远程安装及部署
- 理解MySQL——索引与优化
- python 中 BeautifulSoup 模块
- Linux Socket编程(不限Linux)
- 数据结构基础 背包问题(一) 之 非递归解
- HDU_4547_CD操作(LCA+tarjan)
- A class for dynamic icons in Windows
- Leetcode Delete Node in a Linked List
- Segment Fault(core dumped)
- Android学习笔记之BroadcastReceiver
- Oracle查看对象空间使用情况show_space
- zoj 3329 概率dp 环
- 如何选择创业公司
- windows开启远程桌面
- PS将一幅图片添加绘画效果教程
- Shell中创建命令别名