最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
android ListView中嵌套GridView不完全显示如何解决
时间:2015-01-02 编辑:简简单单 来源:一聚教程网
项目需要,在ListView中显示多张图片,用到了GridView,不过如果使用普通的GridView,Item仅仅只是显示一部分,超出第一行以后的都无法显示了,这个很无语,所以又得继承下GridView重写onMeasure方法去测量子控件的宽高了..
这里只是贴出自定义GridView的代码,直接在xml中使用,ListView的Adapter中调用即可:
代码如下 | 复制代码 |
public class GridViewForListView extends GridView { public GridViewForListView(Context context) { super(context); } public GridViewForListView(Context context, AttributeSet attrs) { super(context, attrs); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec); } } |
相关文章
- Android 开发实现EditText 光标居右显示 04-26
- Android ScrollView嵌套ExpandableListView显示不正常的问题的解决办法 03-28
- Android子控件超出父控件的范围显示出来方法 08-04
- 解决Android中Listview显示错乱问题 12-04
- 深入分析Android中Listview显示错乱问题 12-01
- sora软件价格介绍 02-22