diff options
author | Alan Viverette <alanv@google.com> | 2015-07-29 15:55:20 -0400 |
---|---|---|
committer | Alan Viverette <alanv@google.com> | 2015-07-29 15:55:20 -0400 |
commit | 7a40d21d89682edef07b21110b779e0f1d9cafea (patch) | |
tree | a069615d066e8effeee0efdf5d592f8be283dc7b /core/java/android/widget/RelativeLayout.java | |
parent | 308139425e697536304be55a5865aae7a290fb1d (diff) | |
download | frameworks_base-7a40d21d89682edef07b21110b779e0f1d9cafea.zip frameworks_base-7a40d21d89682edef07b21110b779e0f1d9cafea.tar.gz frameworks_base-7a40d21d89682edef07b21110b779e0f1d9cafea.tar.bz2 |
Ensure maxHeight is at least 0 during measureChildHorizontal()
Bug: 22613599
Change-Id: I11f70ed1f7221874bef0f00f006e0ae294c4bdfa
Diffstat (limited to 'core/java/android/widget/RelativeLayout.java')
-rw-r--r-- | core/java/android/widget/RelativeLayout.java | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/core/java/android/widget/RelativeLayout.java b/core/java/android/widget/RelativeLayout.java index 6a561e6..4dfa7db 100644 --- a/core/java/android/widget/RelativeLayout.java +++ b/core/java/android/widget/RelativeLayout.java @@ -676,33 +676,42 @@ public class RelativeLayout extends ViewGroup { child.measure(childWidthMeasureSpec, childHeightMeasureSpec); } - private void measureChildHorizontal(View child, LayoutParams params, int myWidth, int myHeight) { - int childWidthMeasureSpec = getChildMeasureSpec(params.mLeft, - params.mRight, params.width, - params.leftMargin, params.rightMargin, - mPaddingLeft, mPaddingRight, + private void measureChildHorizontal( + View child, LayoutParams params, int myWidth, int myHeight) { + final int childWidthMeasureSpec = getChildMeasureSpec(params.mLeft, params.mRight, + params.width, params.leftMargin, params.rightMargin, mPaddingLeft, mPaddingRight, myWidth); - int maxHeight = myHeight; - if (mMeasureVerticalWithPaddingMargin) { - maxHeight = Math.max(0, myHeight - mPaddingTop - mPaddingBottom - - params.topMargin - params.bottomMargin); - } - int childHeightMeasureSpec; + + final int childHeightMeasureSpec; if (myHeight < 0 && !mAllowBrokenMeasureSpecs) { if (params.height >= 0) { childHeightMeasureSpec = MeasureSpec.makeMeasureSpec( params.height, MeasureSpec.EXACTLY); } else { - // Negative values in a mySize/myWidth/myWidth value in RelativeLayout measurement - // is code for, "we got an unspecified mode in the RelativeLayout's measurespec." + // Negative values in a mySize/myWidth/myWidth value in + // RelativeLayout measurement is code for, "we got an + // unspecified mode in the RelativeLayout's measure spec." // Carry it forward. childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); } - } else if (params.width == LayoutParams.MATCH_PARENT) { - childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.EXACTLY); } 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); } |