首页 > 其他 > 详细

ScollView嵌套ListView和GridView问题

时间:2015-08-20 09:09:35      阅读:238      评论:0      收藏:0      [点我收藏+]

直接在ScollView中嵌套ListView和GridView的话,ListView和GridView只会显示一部分内容,不能显示完整,需要重写ListView和GridView中的onMeasure方法,代码如下:

下面是重写ListView,GridView用法相同。

public class MyListView extends ListView {

	public MyListView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		// TODO Auto-generated constructor stub
	}

	public MyListView(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
	}

	public MyListView(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
	}

	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		// TODO Auto-generated method stub
		int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
				MeasureSpec.AT_MOST);
		super.onMeasure(widthMeasureSpec, expandSpec);
	}

}


版权声明:本文为博主原创文章,未经博主允许不得转载。

ScollView嵌套ListView和GridView问题

原文:http://blog.csdn.net/u012527802/article/details/47802411

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!