- 关于ScrollView嵌套ExpandableListView导致ExpandableListView显示不正常的问题解决方法有很多,在这里介绍一种小编亲自测试通过的方法。
- 1:不显示chidview:
- 重写ExpandableListView :
- public class CustomExpandableListView extends ExpandableListView {
- public CustomExpandableListView(Context context, AttributeSet attrs) {
- super(context, attrs);
- // 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);
- }
- }
- 在XML中将ExpandableListView替换为重写的ExpandableListView即可。
- 此外:要想显示全最后一个子布局:需要在用到ExpandableListView的布局中设置属性
-
android:divider="@null"
android:dividerHeight="0dp"
当ScrollView内嵌套ExpandableListView时,可能会出现显示异常。通过重写ExpandableListView的onMeasure方法并设置特定属性,可以解决不显示子View的问题。同时,为使所有子布局可见,需在XML中设置ExpandableListView的divider和dividerHeight属性。
2192

被折叠的 条评论
为什么被折叠?



