RelativeLayout不能调用measure去直接测量子元素

RelativeLayout在实现onMeasure方法时并没有像LinearLayout一样去重写如下代码:
  @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        if (mOrientation == VERTICAL) {
            measureVertical(widthMeasureSpec, heightMeasureSpec);
        } else {
            measureHorizontal(widthMeasureSpec, heightMeasureSpec);
        }
    }

所以导致在View.inflate之后无法通知系统测量布局,如果根布局是RelativeLayout。



posted @ 2016-05-01 17:40  soft.push("zzq")  Views(236)  Comments(0Edit  收藏  举报