ScrollView 和 ListView 或ExpandableListView显示冲突问题

来源:互联网 发布:ios看书软件推荐 编辑:程序博客网 时间:2024/06/15 06:43

完成ScrollView 下拉和上提刷新,可以见我分享的资料。

核心说一下 ScrollView 和 ListView 或ExpandableListView显示冲突问题:

  方案一:给ListView 设置固定高度。

  方案二:计算 动态计算 Adpater 的item 数 * item 高度。

  方案三:重写 onMeasure 方法。

   

publicclass AAExpandableListViewextends ExpandableListView {


public AAExpandableListView(Context context, AttributeSet attrs) {

super(context, attrs);

// TODO Auto-generated constructor stub

}

@Override      

protectedvoid 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);

}

}