summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorFabrice Di Meglio <fdimeglio@google.com>2013-01-18 18:36:45 -0800
committerFabrice Di Meglio <fdimeglio@google.com>2013-01-22 13:14:08 -0800
commit547261320cb4bbb3e967246bc86578263d94e84d (patch)
tree4189074ab175d4e6709086e9c928c025605878b3 /core/java
parent0d31c74b2eff3ce37133a2fe9fb57db7d4d84a91 (diff)
downloadframeworks_base-547261320cb4bbb3e967246bc86578263d94e84d.zip
frameworks_base-547261320cb4bbb3e967246bc86578263d94e84d.tar.gz
frameworks_base-547261320cb4bbb3e967246bc86578263d94e84d.tar.bz2
Fix bug #8052320 RelativeLayout is not having the correct width when in RTL mode - part 2
This is a fix for RelativeLayout in RTL mode - visible effect: wrong positioning of components - the width computation (first pass) in RTL mode was wrong: it was missing the application of the horizontal rules before measuring the children horizontally. This is now doing the same as the normal LTR pass (except positioning the component which is done in the second pass) See related issue: bug #8051633 Recent Apps thumbnails in RTL mode (Arabic / Hebrew / Farsi) should be aligned Change-Id: I710de1a504bec8743f8e3c13f6ff850055edb2d2
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/widget/RelativeLayout.java26
1 files changed, 9 insertions, 17 deletions
diff --git a/core/java/android/widget/RelativeLayout.java b/core/java/android/widget/RelativeLayout.java
index e749e63..2b7e162 100644
--- a/core/java/android/widget/RelativeLayout.java
+++ b/core/java/android/widget/RelativeLayout.java
@@ -444,21 +444,14 @@ public class RelativeLayout extends ViewGroup {
// We need to know our size for doing the correct computation of positioning in RTL mode
if (isLayoutRtl() && (myWidth == -1 || isWrapContentWidth)) {
int w = getPaddingStart() + getPaddingEnd();
- final int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
for (int i = 0; i < count; i++) {
View child = views[i];
if (child.getVisibility() != GONE) {
LayoutParams params = (LayoutParams) child.getLayoutParams();
- // Would be similar to a call to measureChildHorizontal(child, params, -1, myHeight)
- // but we cannot change for now the behavior of measureChildHorizontal() for
- // taking care or a "-1" for "mywidth" so use here our own version of that code.
- int childHeightMeasureSpec;
- if (params.width == LayoutParams.MATCH_PARENT) {
- childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(myHeight, MeasureSpec.EXACTLY);
- } else {
- childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(myHeight, MeasureSpec.AT_MOST);
- }
- child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
+ int[] rules = params.getRules(View.LAYOUT_DIRECTION_LTR);
+
+ applyHorizontalSizeRules(params, myWidth, rules);
+ measureChildHorizontal(child, params, -1, myHeight);
w += child.getMeasuredWidth();
w += params.leftMargin + params.rightMargin;
@@ -476,13 +469,16 @@ public class RelativeLayout extends ViewGroup {
}
}
+ final int layoutDirection = getLayoutDirection();
for (int i = 0; i < count; i++) {
View child = views[i];
if (child.getVisibility() != GONE) {
LayoutParams params = (LayoutParams) child.getLayoutParams();
+ int[] rules = params.getRules(layoutDirection);
- applyHorizontalSizeRules(params, myWidth);
+ applyHorizontalSizeRules(params, myWidth, rules);
measureChildHorizontal(child, params, myWidth, myHeight);
+
if (positionChildHorizontal(child, params, myWidth, isWrapContentWidth)) {
offsetHorizontalAxis = true;
}
@@ -543,8 +539,6 @@ public class RelativeLayout extends ViewGroup {
}
}
- final int layoutDirection = getLayoutDirection();
-
if (isWrapContentWidth) {
// Width already has left padding in it since it was calculated by looking at
// the right of each child view
@@ -862,9 +856,7 @@ public class RelativeLayout extends ViewGroup {
return rules[ALIGN_PARENT_BOTTOM] != 0;
}
- private void applyHorizontalSizeRules(LayoutParams childParams, int myWidth) {
- final int layoutDirection = getLayoutDirection();
- int[] rules = childParams.getRules(layoutDirection);
+ private void applyHorizontalSizeRules(LayoutParams childParams, int myWidth, int[] rules) {
RelativeLayout.LayoutParams anchorParams;
// -1 indicated a "soft requirement" in that direction. For example: