Loading core/java/android/widget/RelativeLayout.java +25 −16 Original line number Original line Diff line number Diff line Loading @@ -676,33 +676,42 @@ public class RelativeLayout extends ViewGroup { child.measure(childWidthMeasureSpec, childHeightMeasureSpec); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); } } private void measureChildHorizontal(View child, LayoutParams params, int myWidth, int myHeight) { private void measureChildHorizontal( int childWidthMeasureSpec = getChildMeasureSpec(params.mLeft, View child, LayoutParams params, int myWidth, int myHeight) { params.mRight, params.width, final int childWidthMeasureSpec = getChildMeasureSpec(params.mLeft, params.mRight, params.leftMargin, params.rightMargin, params.width, params.leftMargin, params.rightMargin, mPaddingLeft, mPaddingRight, mPaddingLeft, mPaddingRight, myWidth); myWidth); int maxHeight = myHeight; if (mMeasureVerticalWithPaddingMargin) { final int childHeightMeasureSpec; maxHeight = Math.max(0, myHeight - mPaddingTop - mPaddingBottom - params.topMargin - params.bottomMargin); } int childHeightMeasureSpec; if (myHeight < 0 && !mAllowBrokenMeasureSpecs) { if (myHeight < 0 && !mAllowBrokenMeasureSpecs) { if (params.height >= 0) { if (params.height >= 0) { childHeightMeasureSpec = MeasureSpec.makeMeasureSpec( childHeightMeasureSpec = MeasureSpec.makeMeasureSpec( params.height, MeasureSpec.EXACTLY); params.height, MeasureSpec.EXACTLY); } else { } else { // Negative values in a mySize/myWidth/myWidth value in RelativeLayout measurement // Negative values in a mySize/myWidth/myWidth value in // is code for, "we got an unspecified mode in the RelativeLayout's measurespec." // RelativeLayout measurement is code for, "we got an // unspecified mode in the RelativeLayout's measure spec." // Carry it forward. // Carry it forward. childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); } } } else if (params.width == LayoutParams.MATCH_PARENT) { childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.EXACTLY); } else { } else { childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST); final int maxHeight; if (mMeasureVerticalWithPaddingMargin) { maxHeight = Math.max(0, myHeight - mPaddingTop - mPaddingBottom - params.topMargin - params.bottomMargin); } else { maxHeight = Math.max(0, myHeight); } } final int heightMode; if (params.width == LayoutParams.MATCH_PARENT) { heightMode = MeasureSpec.EXACTLY; } else { heightMode = MeasureSpec.AT_MOST; } childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(maxHeight, heightMode); } child.measure(childWidthMeasureSpec, childHeightMeasureSpec); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); } } Loading Loading
core/java/android/widget/RelativeLayout.java +25 −16 Original line number Original line Diff line number Diff line Loading @@ -676,33 +676,42 @@ public class RelativeLayout extends ViewGroup { child.measure(childWidthMeasureSpec, childHeightMeasureSpec); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); } } private void measureChildHorizontal(View child, LayoutParams params, int myWidth, int myHeight) { private void measureChildHorizontal( int childWidthMeasureSpec = getChildMeasureSpec(params.mLeft, View child, LayoutParams params, int myWidth, int myHeight) { params.mRight, params.width, final int childWidthMeasureSpec = getChildMeasureSpec(params.mLeft, params.mRight, params.leftMargin, params.rightMargin, params.width, params.leftMargin, params.rightMargin, mPaddingLeft, mPaddingRight, mPaddingLeft, mPaddingRight, myWidth); myWidth); int maxHeight = myHeight; if (mMeasureVerticalWithPaddingMargin) { final int childHeightMeasureSpec; maxHeight = Math.max(0, myHeight - mPaddingTop - mPaddingBottom - params.topMargin - params.bottomMargin); } int childHeightMeasureSpec; if (myHeight < 0 && !mAllowBrokenMeasureSpecs) { if (myHeight < 0 && !mAllowBrokenMeasureSpecs) { if (params.height >= 0) { if (params.height >= 0) { childHeightMeasureSpec = MeasureSpec.makeMeasureSpec( childHeightMeasureSpec = MeasureSpec.makeMeasureSpec( params.height, MeasureSpec.EXACTLY); params.height, MeasureSpec.EXACTLY); } else { } else { // Negative values in a mySize/myWidth/myWidth value in RelativeLayout measurement // Negative values in a mySize/myWidth/myWidth value in // is code for, "we got an unspecified mode in the RelativeLayout's measurespec." // RelativeLayout measurement is code for, "we got an // unspecified mode in the RelativeLayout's measure spec." // Carry it forward. // Carry it forward. childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); } } } else if (params.width == LayoutParams.MATCH_PARENT) { childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.EXACTLY); } else { } else { childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST); final int maxHeight; if (mMeasureVerticalWithPaddingMargin) { maxHeight = Math.max(0, myHeight - mPaddingTop - mPaddingBottom - params.topMargin - params.bottomMargin); } else { maxHeight = Math.max(0, myHeight); } } final int heightMode; if (params.width == LayoutParams.MATCH_PARENT) { heightMode = MeasureSpec.EXACTLY; } else { heightMode = MeasureSpec.AT_MOST; } childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(maxHeight, heightMode); } child.measure(childWidthMeasureSpec, childHeightMeasureSpec); child.measure(childWidthMeasureSpec, childHeightMeasureSpec); } } Loading