Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9204810e authored by Alan Viverette's avatar Alan Viverette Committed by android-build-merger
Browse files

Merge "Always assign leftover pixels to last weighted child" into nyc-dev

am: a11c21b4

* commit 'a11c21b4':
  Always assign leftover pixels to last weighted child

Change-Id: Ibfaa979ba23c204172015fae11a767be8a4852dc
parents b78624da a11c21b4
Loading
Loading
Loading
Loading
+24 −6
Original line number Diff line number Diff line
@@ -708,6 +708,7 @@ public class LinearLayout extends ViewGroup {
        final int baselineChildIndex = mBaselineAlignedChildIndex;        
        final boolean useLargestChild = mUseLargestChild;

        int lastWeightedChildIndex = -1;
        int largestChildHeight = Integer.MIN_VALUE;
        int consumedExcessSpace = 0;

@@ -729,8 +730,10 @@ public class LinearLayout extends ViewGroup {
            }

            final LayoutParams lp = (LayoutParams) child.getLayoutParams();

            if (lp.weight > 0) {
                totalWeight += lp.weight;
                lastWeightedChildIndex = i;
            }

            final boolean useExcessSpace = lp.height == 0 && lp.weight > 0;
            if (heightMode == MeasureSpec.EXACTLY && useExcessSpace) {
@@ -885,7 +888,13 @@ public class LinearLayout extends ViewGroup {
                final LayoutParams lp = (LayoutParams) child.getLayoutParams();
                final float childWeight = lp.weight;
                if (childWeight > 0) {
                    final int share = (int) (childWeight * remainingExcess / remainingWeightSum);
                    final int share;
                    if (i == lastWeightedChildIndex) {
                        share = remainingExcess;
                    } else {
                        share = (int) (childWeight * remainingExcess / remainingWeightSum);
                    }

                    remainingExcess -= share;
                    remainingWeightSum -= childWeight;

@@ -1046,6 +1055,7 @@ public class LinearLayout extends ViewGroup {
        
        final boolean isExactly = widthMode == MeasureSpec.EXACTLY;

        int lastWeightedChildIndex = -1;
        int largestChildWidth = Integer.MIN_VALUE;
        int usedExcessSpace = 0;

@@ -1067,8 +1077,10 @@ public class LinearLayout extends ViewGroup {
            }

            final LayoutParams lp = (LayoutParams) child.getLayoutParams();

            if (lp.weight > 0) {
                totalWeight += lp.weight;
                lastWeightedChildIndex = i;
            }

            final boolean useExcessSpace = lp.width == 0 && lp.weight > 0;
            if (widthMode == MeasureSpec.EXACTLY && useExcessSpace) {
@@ -1267,7 +1279,13 @@ public class LinearLayout extends ViewGroup {
                final LayoutParams lp = (LayoutParams) child.getLayoutParams();
                final float childWeight = lp.weight;
                if (childWeight > 0) {
                    final int share = (int) (childWeight * remainingExcess / remainingWeightSum);
                    final int share;
                    if (i == lastWeightedChildIndex) {
                        share = remainingExcess;
                    } else {
                        share = (int) (childWeight * remainingExcess / remainingWeightSum);
                    }

                    remainingExcess -= share;
                    remainingWeightSum -= childWeight;