diff options
| author | 2016-05-05 18:37:41 +0000 | |
|---|---|---|
| committer | 2016-05-05 18:37:43 +0000 | |
| commit | 3a3fb73c753efb2114693b1943246bc6c47f9470 (patch) | |
| tree | cb3031c43c6338067da3d56d3ae16ace357f1188 | |
| parent | 2bea394d14e6e7ae6a183d302d21ce1deacf4774 (diff) | |
| parent | 61c41bf6175222c265973b5fb0063b3e3c5d02c8 (diff) | |
Merge "Revert "Always assign leftover pixels to last weighted child"" into nyc-dev
| -rw-r--r-- | core/java/android/widget/LinearLayout.java | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/core/java/android/widget/LinearLayout.java b/core/java/android/widget/LinearLayout.java index 0b73afb657f7..f75b74bb9a14 100644 --- a/core/java/android/widget/LinearLayout.java +++ b/core/java/android/widget/LinearLayout.java @@ -708,7 +708,6 @@ public class LinearLayout extends ViewGroup { final int baselineChildIndex = mBaselineAlignedChildIndex; final boolean useLargestChild = mUseLargestChild; - int lastWeightedChildIndex = -1; int largestChildHeight = Integer.MIN_VALUE; int consumedExcessSpace = 0; @@ -730,10 +729,8 @@ public class LinearLayout extends ViewGroup { } final LayoutParams lp = (LayoutParams) child.getLayoutParams(); - if (lp.weight > 0) { - totalWeight += lp.weight; - lastWeightedChildIndex = i; - } + + totalWeight += lp.weight; final boolean useExcessSpace = lp.height == 0 && lp.weight > 0; if (heightMode == MeasureSpec.EXACTLY && useExcessSpace) { @@ -888,13 +885,7 @@ public class LinearLayout extends ViewGroup { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); final float childWeight = lp.weight; if (childWeight > 0) { - final int share; - if (i == lastWeightedChildIndex) { - share = remainingExcess; - } else { - share = (int) (childWeight * remainingExcess / remainingWeightSum); - } - + final int share = (int) (childWeight * remainingExcess / remainingWeightSum); remainingExcess -= share; remainingWeightSum -= childWeight; @@ -1055,7 +1046,6 @@ public class LinearLayout extends ViewGroup { final boolean isExactly = widthMode == MeasureSpec.EXACTLY; - int lastWeightedChildIndex = -1; int largestChildWidth = Integer.MIN_VALUE; int usedExcessSpace = 0; @@ -1077,10 +1067,8 @@ public class LinearLayout extends ViewGroup { } final LayoutParams lp = (LayoutParams) child.getLayoutParams(); - if (lp.weight > 0) { - totalWeight += lp.weight; - lastWeightedChildIndex = i; - } + + totalWeight += lp.weight; final boolean useExcessSpace = lp.width == 0 && lp.weight > 0; if (widthMode == MeasureSpec.EXACTLY && useExcessSpace) { @@ -1279,13 +1267,7 @@ public class LinearLayout extends ViewGroup { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); final float childWeight = lp.weight; if (childWeight > 0) { - final int share; - if (i == lastWeightedChildIndex) { - share = remainingExcess; - } else { - share = (int) (childWeight * remainingExcess / remainingWeightSum); - } - + final int share = (int) (childWeight * remainingExcess / remainingWeightSum); remainingExcess -= share; remainingWeightSum -= childWeight; |