diff options
author | Adam Powell <adamp@google.com> | 2012-09-30 14:24:52 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-09-30 14:24:53 -0700 |
commit | fb42be77ea88470c71f2ad1e03bff7fdc3721465 (patch) | |
tree | 7d8ae524aafb040dadecfe2a2a0d7bbad1ae1775 | |
parent | 933a7546c857dba7704a15b7f7f7847934f14912 (diff) | |
parent | 132a742b94b9716451ddef30cec20548b346f1b9 (diff) | |
download | frameworks_base-fb42be77ea88470c71f2ad1e03bff7fdc3721465.zip frameworks_base-fb42be77ea88470c71f2ad1e03bff7fdc3721465.tar.gz frameworks_base-fb42be77ea88470c71f2ad1e03bff7fdc3721465.tar.bz2 |
Merge "Fix UNSPECIFIED measurement in RelativeLayout" into jb-mr1-dev
-rw-r--r-- | core/java/android/widget/RelativeLayout.java | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/core/java/android/widget/RelativeLayout.java b/core/java/android/widget/RelativeLayout.java index 455355f..5f46d89 100644 --- a/core/java/android/widget/RelativeLayout.java +++ b/core/java/android/widget/RelativeLayout.java @@ -369,10 +369,10 @@ public class RelativeLayout extends ViewGroup { int width = 0; int height = 0; - int widthMode = MeasureSpec.getMode(widthMeasureSpec); - int heightMode = MeasureSpec.getMode(heightMeasureSpec); - int widthSize = MeasureSpec.getSize(widthMeasureSpec); - int heightSize = MeasureSpec.getSize(heightMeasureSpec); + final int widthMode = MeasureSpec.getMode(widthMeasureSpec); + final int heightMode = MeasureSpec.getMode(heightMeasureSpec); + final int widthSize = MeasureSpec.getSize(widthMeasureSpec); + final int heightSize = MeasureSpec.getSize(heightMeasureSpec); // Record our dimensions if they are known; if (widthMode != MeasureSpec.UNSPECIFIED) { @@ -637,7 +637,12 @@ public class RelativeLayout extends ViewGroup { mPaddingLeft, mPaddingRight, myWidth); int childHeightMeasureSpec; - if (params.width == LayoutParams.MATCH_PARENT) { + if (myHeight < 0) { + // Negative values in a mySize/myWidth/myWidth value in RelativeLayout measurement + // is code for, "we got an unspecified mode in the RelativeLayout's measurespec." + // Carry it forward. + childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); + } else if (params.width == LayoutParams.MATCH_PARENT) { childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(myHeight, MeasureSpec.EXACTLY); } else { childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(myHeight, MeasureSpec.AT_MOST); @@ -664,6 +669,13 @@ public class RelativeLayout extends ViewGroup { private int getChildMeasureSpec(int childStart, int childEnd, int childSize, int startMargin, int endMargin, int startPadding, int endPadding, int mySize) { + if (mySize < 0) { + // Negative values in a mySize/myWidth/myWidth value in RelativeLayout measurement + // is code for, "we got an unspecified mode in the RelativeLayout's measurespec." + // Carry it forward. + return MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); + } + int childSpecMode = 0; int childSpecSize = 0; |