Android ScrollView嵌套ExpandableListView显示不正常的问题的解决办法

来源:互联网 发布:热血屠龙进阶数据 编辑:程序博客网 时间:2024/05/22 11:54
  1.   关于ScrollView嵌套ExpandableListView导致ExpandableListView显示不正常的问题解决方法有很多,在这里介绍一种小编亲自测试通过的方法。
  2. 1:不显示chidview:
  3. 重写ExpandableListView :
  4. public class CustomExpandableListView extends ExpandableListView {  
  5.   
  6.     public CustomExpandableListView(Context context, AttributeSet attrs) {  
  7.         super(context, attrs);  
  8.         // TODO Auto-generated constructor stub  
  9.     }  
  10.   
  11.     @Override  
  12.     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {  
  13.         // TODO Auto-generated method stub  
  14.         int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,  
  15.   
  16.         MeasureSpec.AT_MOST);  
  17.   
  18.         super.onMeasure(widthMeasureSpec, expandSpec);  
  19.     }  

  1. }  
  2. 在XML中将ExpandableListView替换为重写的ExpandableListView即可。
  3. 此外:要想显示全最后一个子布局:需要在用到ExpandableListView的布局中设置属性
  4. android:divider="@null"
    android:dividerHeight="0dp"




阅读全文
0 0
原创粉丝点击