Android HorizontalScrollView嵌套CustomView

在HorizontalScrollView中如果要嵌套CustomView,要在CustomView的onMeasure方法设置CustomView的宽高,不然CustomView不能显示出来。
@Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int width = MeasureSpec.getSize(widthMeasureSpec);
        int height = MeasureSpec.getSize(heightMeasureSpec);
        setMeasuredDimension(width, height);
    }

猜你喜欢

转载自newcrazy.iteye.com/blog/2202186