if (!allFillParent && widthMode != MeasureSpec.EXACTLY) {
maxWidth = alternativeMaxWidth;
}
maxWidth += mPaddingLeft + mPaddingRight;
// Check against our minimum width
maxWidth = Math.max(maxWidth, getSuggestedMinimumWidth());
setMeasuredDimension(resolveSizeAndState(maxWidth, widthMeasureSpec, childState),
heightSizeAndState);
if (matchWidth) {
forceUniformWidth(count, heightMeasureSpec);
}
- 判断allFillParent以及widthMode,如果满足的话,那么maxWidth则设为alternativeMaxWidth
- maxWidth再加上左右的间距
- 比较和背景图的大小
- 通过resolveSizeAndState获取widthMeasureSpec,通过setMeasuredDimension设置LinearLayout的宽高