RelativeLayout在实现onMeasure方法时并没有像LinearLayout一样去重写如下代码:
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (mOrientation == VERTICAL) {
measureVertical(widthMeasureSpec, heightMeasureSpec);
} else {
measureHorizontal(widthMeasureSpec, heightMeasureSpec);
}
}
所以导致在View.inflate之后无法通知系统测量布局,如果根布局是RelativeLayout。