直接嵌套会有问题,要解决这个冲突,只需要重写ListView,然后给ListView重新测量下就行了。
代码如下:
@Override
protected void onMeasure(int widthSpec, int heightSpec) {
int newHeightSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
MeasureSpec.AT_MOST);
super.onMeasure(widthSpec, newHeightSpec);
}经测试,在RecyclerView使用上述方法同样可以。
本文介绍了一种解决Android中嵌套ListView高度自适应的方法,通过重写ListView并调整其测量方式来解决高度冲突的问题。该方法同样适用于RecyclerView。
3904

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



