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

Commit 95607038 authored by Romain Guy's avatar Romain Guy
Browse files

Reverse the order in which RelativeLayout measures and positions children.

This fixes RelativeLayouts with height=wrap_content.
parent ae7c980e
Loading
Loading
Loading
Loading
+14 −12
Original line number Diff line number Diff line
@@ -349,9 +349,10 @@ public class RelativeLayout extends ViewGroup {
            View child = views[i];
            if (child.getVisibility() != GONE) {
                LayoutParams params = (LayoutParams) child.getLayoutParams();
                applyVerticalSizeRules(params, myHeight);
                measureChildVertical(child, params, myHeight);
                positionChildVertical(child, params, myHeight);

                applyHorizontalSizeRules(params, myWidth);
                measureChildHorizontal(child, params, myWidth);
                positionChildHorizontal(child, params, myWidth);
            }
        }

@@ -361,9 +362,10 @@ public class RelativeLayout extends ViewGroup {
            View child = views[i];
            if (child.getVisibility() != GONE) {
                LayoutParams params = (LayoutParams) child.getLayoutParams();
                applyHorizontalSizeRules(params, myWidth);
                
                applyVerticalSizeRules(params, myHeight);
                measureChild(child, params, myWidth, myHeight);
                positionChildHorizontal(child, params, myWidth);
                positionChildVertical(child, params, myHeight);

                if (widthMode != MeasureSpec.EXACTLY) {
                    width = Math.max(width, params.mRight);
@@ -508,13 +510,13 @@ public class RelativeLayout extends ViewGroup {
        child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
    }

    private void measureChildVertical(View child, LayoutParams params, int myHeight) {
        int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
        int childHeightMeasureSpec = getChildMeasureSpec(params.mTop,
                params.mBottom, params.height,
                params.topMargin, params.bottomMargin,
                mPaddingTop, mPaddingBottom,
                myHeight);
    private void measureChildHorizontal(View child, LayoutParams params, int myWidth) {
        int childWidthMeasureSpec = getChildMeasureSpec(params.mLeft,
                params.mRight, params.width,
                params.leftMargin, params.rightMargin,
                mPaddingLeft, mPaddingRight,
                myWidth);
        int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
        child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
    }