diff options
| -rw-r--r-- | core/java/android/util/LayoutDirection.java | 6 | ||||
| -rw-r--r-- | core/java/android/view/View.java | 6 | ||||
| -rw-r--r-- | core/java/android/widget/LinearLayout.java | 13 |
3 files changed, 25 insertions, 0 deletions
diff --git a/core/java/android/util/LayoutDirection.java b/core/java/android/util/LayoutDirection.java index 20af20b..03077e4 100644 --- a/core/java/android/util/LayoutDirection.java +++ b/core/java/android/util/LayoutDirection.java @@ -27,6 +27,12 @@ public final class LayoutDirection { private LayoutDirection() {} /** + * An undefined layout direction. + * @hide + */ + public static final int UNDEFINED = -1; + + /** * Horizontal layout direction is from Left to Right. */ public static final int LTR = 0; diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 342315b..5dd5ab8 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -1872,6 +1872,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, public @interface ResolvedLayoutDir {} /** + * A flag to indicate that the layout direction of this view has not been defined yet. + * @hide + */ + public static final int LAYOUT_DIRECTION_UNDEFINED = LayoutDirection.UNDEFINED; + + /** * Horizontal layout direction of this view is from Left to Right. * Use with {@link #setLayoutDirection}. */ diff --git a/core/java/android/widget/LinearLayout.java b/core/java/android/widget/LinearLayout.java index f153ce5..9d14254 100644 --- a/core/java/android/widget/LinearLayout.java +++ b/core/java/android/widget/LinearLayout.java @@ -185,6 +185,8 @@ public class LinearLayout extends ViewGroup { private int mShowDividers; private int mDividerPadding; + private int mLayoutDirection = View.LAYOUT_DIRECTION_UNDEFINED; + public LinearLayout(Context context) { this(context, null); } @@ -1567,6 +1569,17 @@ public class LinearLayout extends ViewGroup { } } + @Override + public void onRtlPropertiesChanged(@ResolvedLayoutDir int layoutDirection) { + super.onRtlPropertiesChanged(layoutDirection); + if (layoutDirection != mLayoutDirection) { + mLayoutDirection = layoutDirection; + if (mOrientation == HORIZONTAL) { + requestLayout(); + } + } + } + /** * Position the children during a layout pass if the orientation of this * LinearLayout is set to {@link #HORIZONTAL}. |
