diff options
author | Alan Viverette <alanv@google.com> | 2014-02-24 18:21:09 -0800 |
---|---|---|
committer | Alan Viverette <alanv@google.com> | 2014-02-24 18:21:09 -0800 |
commit | 65be9cc34c1619d3ba71726c821820f394b694ab (patch) | |
tree | 891b792a00732a98679271cc73617f881cb7d86f /core/java | |
parent | 3651cb7b4a0c3c731905301e868cca1c3af5aa21 (diff) | |
download | frameworks_base-65be9cc34c1619d3ba71726c821820f394b694ab.zip frameworks_base-65be9cc34c1619d3ba71726c821820f394b694ab.tar.gz frameworks_base-65be9cc34c1619d3ba71726c821820f394b694ab.tar.bz2 |
Force measurement in LinearLayout if any views are skipped
BUG: 12249256
Change-Id: I805cc70c4a2982befd9eb625be1378e6a2d9eba6
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/widget/LinearLayout.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/core/java/android/widget/LinearLayout.java b/core/java/android/widget/LinearLayout.java index 65f1ab7..82e624d 100644 --- a/core/java/android/widget/LinearLayout.java +++ b/core/java/android/widget/LinearLayout.java @@ -667,6 +667,7 @@ public class LinearLayout extends ViewGroup { final int heightMode = MeasureSpec.getMode(heightMeasureSpec); boolean matchWidth = false; + boolean skippedMeasure = false; final int baselineChildIndex = mBaselineAlignedChildIndex; final boolean useLargestChild = mUseLargestChild; @@ -701,6 +702,7 @@ public class LinearLayout extends ViewGroup { // there is any leftover space. final int totalLength = mTotalLength; mTotalLength = Math.max(totalLength, totalLength + lp.topMargin + lp.bottomMargin); + skippedMeasure = true; } else { int oldHeight = Integer.MIN_VALUE; @@ -827,9 +829,10 @@ public class LinearLayout extends ViewGroup { heightSize = heightSizeAndState & MEASURED_SIZE_MASK; // Either expand children with weight to take up available space or - // shrink them if they extend beyond our current bounds + // shrink them if they extend beyond our current bounds. If we skipped + // measurement on any children, we need to measure them now. int delta = heightSize - mTotalLength; - if (delta != 0 && totalWeight > 0.0f) { + if (skippedMeasure || delta != 0 && totalWeight > 0.0f) { float weightSum = mWeightSum > 0.0f ? mWeightSum : totalWeight; mTotalLength = 0; @@ -995,6 +998,7 @@ public class LinearLayout extends ViewGroup { final int heightMode = MeasureSpec.getMode(heightMeasureSpec); boolean matchHeight = false; + boolean skippedMeasure = false; if (mMaxAscent == null || mMaxDescent == null) { mMaxAscent = new int[VERTICAL_GRAVITY_COUNT]; @@ -1057,6 +1061,8 @@ public class LinearLayout extends ViewGroup { if (baselineAligned) { final int freeSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); child.measure(freeSpec, freeSpec); + } else { + skippedMeasure = true; } } else { int oldWidth = Integer.MIN_VALUE; @@ -1205,9 +1211,10 @@ public class LinearLayout extends ViewGroup { widthSize = widthSizeAndState & MEASURED_SIZE_MASK; // Either expand children with weight to take up available space or - // shrink them if they extend beyond our current bounds + // shrink them if they extend beyond our current bounds. If we skipped + // measurement on any children, we need to measure them now. int delta = widthSize - mTotalLength; - if (delta != 0 && totalWeight > 0.0f) { + if (skippedMeasure || delta != 0 && totalWeight > 0.0f) { float weightSum = mWeightSum > 0.0f ? mWeightSum : totalWeight; maxAscent[0] = maxAscent[1] = maxAscent[2] = maxAscent[3] = -1; |