你需要在自定义ViewGroup中重写onMeasure方法,用来计算ViewGroup所需要的宽度和高度,然后setMeasuredDimension(width, height);
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { //省略计算过程 setMeasuredDimension(720, 2000); }
然后你就惊奇的发现可以了,,,,,我靠!!!!