Merge "Revert "Always assign leftover pixels to last weighted child"" into nyc-dev
am: 3a3fb73c75
* commit '3a3fb73c753efb2114693b1943246bc6c47f9470':
Revert "Always assign leftover pixels to last weighted child"
Change-Id: I292d86c36049afe621f559d01a12976c9f6068ca
This commit is contained in:
@@ -708,7 +708,6 @@ public class LinearLayout extends ViewGroup {
|
|||||||
final int baselineChildIndex = mBaselineAlignedChildIndex;
|
final int baselineChildIndex = mBaselineAlignedChildIndex;
|
||||||
final boolean useLargestChild = mUseLargestChild;
|
final boolean useLargestChild = mUseLargestChild;
|
||||||
|
|
||||||
int lastWeightedChildIndex = -1;
|
|
||||||
int largestChildHeight = Integer.MIN_VALUE;
|
int largestChildHeight = Integer.MIN_VALUE;
|
||||||
int consumedExcessSpace = 0;
|
int consumedExcessSpace = 0;
|
||||||
|
|
||||||
@@ -730,10 +729,8 @@ public class LinearLayout extends ViewGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
||||||
if (lp.weight > 0) {
|
|
||||||
totalWeight += lp.weight;
|
totalWeight += lp.weight;
|
||||||
lastWeightedChildIndex = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
final boolean useExcessSpace = lp.height == 0 && lp.weight > 0;
|
final boolean useExcessSpace = lp.height == 0 && lp.weight > 0;
|
||||||
if (heightMode == MeasureSpec.EXACTLY && useExcessSpace) {
|
if (heightMode == MeasureSpec.EXACTLY && useExcessSpace) {
|
||||||
@@ -888,13 +885,7 @@ public class LinearLayout extends ViewGroup {
|
|||||||
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
||||||
final float childWeight = lp.weight;
|
final float childWeight = lp.weight;
|
||||||
if (childWeight > 0) {
|
if (childWeight > 0) {
|
||||||
final int share;
|
final int share = (int) (childWeight * remainingExcess / remainingWeightSum);
|
||||||
if (i == lastWeightedChildIndex) {
|
|
||||||
share = remainingExcess;
|
|
||||||
} else {
|
|
||||||
share = (int) (childWeight * remainingExcess / remainingWeightSum);
|
|
||||||
}
|
|
||||||
|
|
||||||
remainingExcess -= share;
|
remainingExcess -= share;
|
||||||
remainingWeightSum -= childWeight;
|
remainingWeightSum -= childWeight;
|
||||||
|
|
||||||
@@ -1055,7 +1046,6 @@ public class LinearLayout extends ViewGroup {
|
|||||||
|
|
||||||
final boolean isExactly = widthMode == MeasureSpec.EXACTLY;
|
final boolean isExactly = widthMode == MeasureSpec.EXACTLY;
|
||||||
|
|
||||||
int lastWeightedChildIndex = -1;
|
|
||||||
int largestChildWidth = Integer.MIN_VALUE;
|
int largestChildWidth = Integer.MIN_VALUE;
|
||||||
int usedExcessSpace = 0;
|
int usedExcessSpace = 0;
|
||||||
|
|
||||||
@@ -1077,10 +1067,8 @@ public class LinearLayout extends ViewGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
||||||
if (lp.weight > 0) {
|
|
||||||
totalWeight += lp.weight;
|
totalWeight += lp.weight;
|
||||||
lastWeightedChildIndex = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
final boolean useExcessSpace = lp.width == 0 && lp.weight > 0;
|
final boolean useExcessSpace = lp.width == 0 && lp.weight > 0;
|
||||||
if (widthMode == MeasureSpec.EXACTLY && useExcessSpace) {
|
if (widthMode == MeasureSpec.EXACTLY && useExcessSpace) {
|
||||||
@@ -1279,13 +1267,7 @@ public class LinearLayout extends ViewGroup {
|
|||||||
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
||||||
final float childWeight = lp.weight;
|
final float childWeight = lp.weight;
|
||||||
if (childWeight > 0) {
|
if (childWeight > 0) {
|
||||||
final int share;
|
final int share = (int) (childWeight * remainingExcess / remainingWeightSum);
|
||||||
if (i == lastWeightedChildIndex) {
|
|
||||||
share = remainingExcess;
|
|
||||||
} else {
|
|
||||||
share = (int) (childWeight * remainingExcess / remainingWeightSum);
|
|
||||||
}
|
|
||||||
|
|
||||||
remainingExcess -= share;
|
remainingExcess -= share;
|
||||||
remainingWeightSum -= childWeight;
|
remainingWeightSum -= childWeight;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user