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

Commit 7c5375d9 authored by Alan Viverette's avatar Alan Viverette Committed by The Android Automerger
Browse files

Include non-zero dimension views in excess space calculation

Bug: 22840778
Change-Id: Iba44c59bbaa48f63b26f342e0510b4c421e8748b
parent bf6b60c9
Loading
Loading
Loading
Loading
+30 −18
Original line number Diff line number Diff line
@@ -723,7 +723,9 @@ public class LinearLayout extends ViewGroup {

            totalWeight += lp.weight;

            if (heightMode == MeasureSpec.EXACTLY && lp.height == 0 && lp.weight > 0) {
            final boolean fillExcessSpace = lp.weight > 0;
            final boolean hasZeroHeight = lp.height == 0;
            if (heightMode == MeasureSpec.EXACTLY && fillExcessSpace && hasZeroHeight) {
                // Optimization: don't bother measuring children who are going to use
                // leftover space. These views will get measured again down below if
                // there is any leftover space.
@@ -731,12 +733,12 @@ public class LinearLayout extends ViewGroup {
                mTotalLength = Math.max(totalLength, totalLength + lp.topMargin + lp.bottomMargin);
                skippedMeasure = true;
            } else {
                final boolean fillExcessSpace = lp.height == 0 && lp.weight > 0;
                if (fillExcessSpace) {
                    // heightMode is either UNSPECIFIED or AT_MOST, and this
                    // child wanted to stretch to fill available space.
                    // Translate that to WRAP_CONTENT so that it does not end up
                    // with a height of 0.
                if (fillExcessSpace && hasZeroHeight) {
                    // The LinearLayout's heightMode is either UNSPECIFIED or
                    // AT_MOST, and this child wanted to stretch to fill
                    // available space. Translate the explicit height of 0 to
                    // WRAP_CONTENT so that we can measure the view's ideal
                    // height.
                    lp.height = LayoutParams.WRAP_CONTENT;
                }

@@ -751,8 +753,12 @@ public class LinearLayout extends ViewGroup {
                final int childHeight = child.getMeasuredHeight();
                if (fillExcessSpace) {
                    usedExcessSpace += childHeight;

                    // Restore original layout height.
                    if (hasZeroHeight) {
                        lp.height = 0;
                    }
                }

                final int totalLength = mTotalLength;
                mTotalLength = Math.max(totalLength, totalLength + childHeight + lp.topMargin +
@@ -1048,7 +1054,9 @@ public class LinearLayout extends ViewGroup {

            totalWeight += lp.weight;

            if (widthMode == MeasureSpec.EXACTLY && lp.width == 0 && lp.weight > 0) {
            final boolean fillExcessSpace = lp.weight > 0;
            final boolean hasZeroWidth = lp.width == 0;
            if (widthMode == MeasureSpec.EXACTLY && fillExcessSpace && hasZeroWidth) {
                // Optimization: don't bother measuring children who are going to use
                // leftover space. These views will get measured again down below if
                // there is any leftover space.
@@ -1075,12 +1083,12 @@ public class LinearLayout extends ViewGroup {
                    skippedMeasure = true;
                }
            } else {
                final boolean fillExcessSpace = lp.width == 0 && lp.weight > 0;
                if (fillExcessSpace) {
                    // widthMode is either UNSPECIFIED or AT_MOST, and this
                    // child wanted to stretch to fill available space.
                    // Translate that to WRAP_CONTENT so that it does not end up
                    // with a width of 0.
                if (fillExcessSpace && hasZeroWidth) {
                    // The LinearLayout's widthMode is either UNSPECIFIED or
                    // AT_MOST, and this child wanted to stretch to fill
                    // available space. Translate the explicit height of 0 to
                    // WRAP_CONTENT so that we can measure the view's ideal
                    // width.
                    lp.width = LayoutParams.WRAP_CONTENT;
                }

@@ -1095,8 +1103,12 @@ public class LinearLayout extends ViewGroup {
                final int childWidth = child.getMeasuredWidth();
                if (fillExcessSpace) {
                    usedExcessSpace += childWidth;

                    // Restore the original layout width.
                    if (hasZeroWidth) {
                        lp.width = 0;
                    }
                }

                if (isExactly) {
                    mTotalLength += childWidth + lp.leftMargin + lp.rightMargin +