summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2017-07-05 23:45:24 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2017-07-05 23:45:24 +0000
commit60b108d75815e1ec10e5198c59808fdc46d5db33 (patch)
tree378e9f142bf34ff28e33fabd20849518a88bf773
parentc952978bfb30b9a6191792d959d4d758440ee8df (diff)
parentbcd3520be634388a89ec52715a1b3644ba227899 (diff)
Merge "Fix RTL issue in RelativeLayout"
-rw-r--r--core/java/android/widget/RelativeLayout.java21
-rw-r--r--core/res/res/layout-land/time_picker_material.xml2
2 files changed, 13 insertions, 10 deletions
diff --git a/core/java/android/widget/RelativeLayout.java b/core/java/android/widget/RelativeLayout.java
index 181ad31deddc..33e65214996b 100644
--- a/core/java/android/widget/RelativeLayout.java
+++ b/core/java/android/widget/RelativeLayout.java
@@ -833,25 +833,28 @@ public class RelativeLayout extends ViewGroup {
if (!wrapContent) {
centerHorizontal(child, params, myWidth);
} else {
- params.mLeft = mPaddingLeft + params.leftMargin;
- params.mRight = params.mLeft + child.getMeasuredWidth();
+ positionAtEdge(child, params, myWidth);
}
return true;
} else {
// This is the default case. For RTL we start from the right and for LTR we start
// from the left. This will give LEFT/TOP for LTR and RIGHT/TOP for RTL.
- if (isLayoutRtl()) {
- params.mRight = myWidth - mPaddingRight- params.rightMargin;
- params.mLeft = params.mRight - child.getMeasuredWidth();
- } else {
- params.mLeft = mPaddingLeft + params.leftMargin;
- params.mRight = params.mLeft + child.getMeasuredWidth();
- }
+ positionAtEdge(child, params, myWidth);
}
}
return rules[ALIGN_PARENT_END] != 0;
}
+ private void positionAtEdge(View child, LayoutParams params, int myWidth) {
+ if (isLayoutRtl()) {
+ params.mRight = myWidth - mPaddingRight - params.rightMargin;
+ params.mLeft = params.mRight - child.getMeasuredWidth();
+ } else {
+ params.mLeft = mPaddingLeft + params.leftMargin;
+ params.mRight = params.mLeft + child.getMeasuredWidth();
+ }
+ }
+
private boolean positionChildVertical(View child, LayoutParams params, int myHeight,
boolean wrapContent) {
diff --git a/core/res/res/layout-land/time_picker_material.xml b/core/res/res/layout-land/time_picker_material.xml
index d83ccb23f64f..dc47dcf7a6ce 100644
--- a/core/res/res/layout-land/time_picker_material.xml
+++ b/core/res/res/layout-land/time_picker_material.xml
@@ -17,7 +17,6 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- android:layoutDirection="ltr"
android:layout_width="match_parent"
android:layout_height="wrap_content">
@@ -34,6 +33,7 @@
android:layoutDirection="ltr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_centerHorizontal="true"
android:paddingTop="@dimen/timepicker_radial_picker_top_margin"
android:orientation="horizontal">