首页 > 其他 > 详细

ScrollView内嵌ListView

时间:2017-09-08 19:04:23      阅读:247      评论:0      收藏:0      [点我收藏+]

对于ScrollView内嵌ListView,我们需要解决两个问题。

1.ListView在layout_height为以下三种任何一种情况的时候,仅一个item可见的问题。

    wrap_content

              match_parent

    0dp+ layout_weight = 1

解决方案:

  1.给ListView设置固定height。

  2.继承ListView重写onMeasure().如

protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int size = MeasureSpec.getSize(heightMeasureSpec);
int mode = MeasureSpec.getMode(heightMeasureSpec);
Log.d(TAG, "onMeasure size = " + size + " mode = " + mode);
int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 3, MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec,expandSpec );
}

2.ListView内的元素无法滑动的问题。

解决方案

 

            

ScrollView内嵌ListView

原文:http://www.cnblogs.com/jianglijs/p/7495930.html

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