Reverse the order in which RelativeLayout measures and positions children.
This fixes RelativeLayouts with height=wrap_content.
This commit is contained in:
@@ -349,9 +349,10 @@ public class RelativeLayout extends ViewGroup {
|
|||||||
View child = views[i];
|
View child = views[i];
|
||||||
if (child.getVisibility() != GONE) {
|
if (child.getVisibility() != GONE) {
|
||||||
LayoutParams params = (LayoutParams) child.getLayoutParams();
|
LayoutParams params = (LayoutParams) child.getLayoutParams();
|
||||||
applyVerticalSizeRules(params, myHeight);
|
|
||||||
measureChildVertical(child, params, myHeight);
|
applyHorizontalSizeRules(params, myWidth);
|
||||||
positionChildVertical(child, params, myHeight);
|
measureChildHorizontal(child, params, myWidth);
|
||||||
|
positionChildHorizontal(child, params, myWidth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -361,9 +362,10 @@ public class RelativeLayout extends ViewGroup {
|
|||||||
View child = views[i];
|
View child = views[i];
|
||||||
if (child.getVisibility() != GONE) {
|
if (child.getVisibility() != GONE) {
|
||||||
LayoutParams params = (LayoutParams) child.getLayoutParams();
|
LayoutParams params = (LayoutParams) child.getLayoutParams();
|
||||||
applyHorizontalSizeRules(params, myWidth);
|
|
||||||
|
applyVerticalSizeRules(params, myHeight);
|
||||||
measureChild(child, params, myWidth, myHeight);
|
measureChild(child, params, myWidth, myHeight);
|
||||||
positionChildHorizontal(child, params, myWidth);
|
positionChildVertical(child, params, myHeight);
|
||||||
|
|
||||||
if (widthMode != MeasureSpec.EXACTLY) {
|
if (widthMode != MeasureSpec.EXACTLY) {
|
||||||
width = Math.max(width, params.mRight);
|
width = Math.max(width, params.mRight);
|
||||||
@@ -508,13 +510,13 @@ public class RelativeLayout extends ViewGroup {
|
|||||||
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
|
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void measureChildVertical(View child, LayoutParams params, int myHeight) {
|
private void measureChildHorizontal(View child, LayoutParams params, int myWidth) {
|
||||||
int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
|
int childWidthMeasureSpec = getChildMeasureSpec(params.mLeft,
|
||||||
int childHeightMeasureSpec = getChildMeasureSpec(params.mTop,
|
params.mRight, params.width,
|
||||||
params.mBottom, params.height,
|
params.leftMargin, params.rightMargin,
|
||||||
params.topMargin, params.bottomMargin,
|
mPaddingLeft, mPaddingRight,
|
||||||
mPaddingTop, mPaddingBottom,
|
myWidth);
|
||||||
myHeight);
|
int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
|
||||||
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
|
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user