天天看點

Android ScrollView嵌套ExpandableListView顯示不正常的問題的解決辦法

  1.   關于ScrollView嵌套ExpandableListView導緻ExpandableListView顯示不正常的問題解決方法有很多,在這裡介紹一種小編親自測試通過的方法。
  2. 1:不顯示chidview:
  3. 重寫ExpandableListView :
  4. public class CustomExpandableListView extends ExpandableListView {  
  5.     public CustomExpandableListView(Context context, AttributeSet attrs) {  
  6.         super(context, attrs);  
  7.         // TODO Auto-generated constructor stub  
  8.     }  
  9.     @Override  
  10.     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {  
  11.         // TODO Auto-generated method stub  
  12.         int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,  
  13.         MeasureSpec.AT_MOST);  
  14.         super.onMeasure(widthMeasureSpec, expandSpec);  
  15.     }  
  1. }  
  2. 在XML中将ExpandableListView替換為重寫的ExpandableListView即可。
  3. 此外:要想顯示全最後一個子布局:需要在用到ExpandableListView的布局中設定屬性
  4. android:divider="@null"
          
    android:dividerHeight="0dp"