ListView 和 GridView 与 ScrollView的冲突


为了解决显示和滚动的问题,可以强制让 ListView 和 GridView 在测量时使用 wrap_content


public class XListView extends ListView {
    ...

    @Override

    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

        int heightSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE>>2,MeasureSpec.AT_MOST);

        super.onMeasure(widthMeasureSpec, heightSpec);
    }

}


GridView 也是如此

猜你喜欢

转载自blog.csdn.net/qq_40054213/article/details/80430151