直接嵌套会有问题,要解决这个冲突,只需要重写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使用上述方法同样可以。