嵌套后ExpandableListView子项的高度只能显示一项,想着怎么处理搜索了半天找到个贼简单的方法。重写ExpandableListView就可以了。其中父ExpandableListView用原来的,子ExpandableListView用重写的就好,留个记录。
public class CustomExpandableListView extends ExpandableListView { public CustomExpandableListView(Context context) { super(context); } public CustomExpandableListView(Context context, AttributeSet attrs) { super(context, attrs); } public CustomExpandableListView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // 处理嵌套场景下,数据显示不完整的问题,更换绘制高度 super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST)); } }