diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2013-02-19 15:59:21 -0800 |
---|---|---|
committer | Fabrice Di Meglio <fdimeglio@google.com> | 2013-03-05 13:07:08 -0800 |
commit | d5ffc79fc8c94df58509c4881b18e64cd922960e (patch) | |
tree | dbc5e947d96232929786b711bad8a79768f945d5 /core/java/android/widget | |
parent | c7ede61f592a2389790ce0993b8ee0a16de54b5e (diff) | |
download | frameworks_base-d5ffc79fc8c94df58509c4881b18e64cd922960e.zip frameworks_base-d5ffc79fc8c94df58509c4881b18e64cd922960e.tar.gz frameworks_base-d5ffc79fc8c94df58509c4881b18e64cd922960e.tar.bz2 |
Improve RTL code for RelativeLayout
- instead of passing the screen size as a constant for computing the
layout size in RTL mode, we just use a real constant. Any value would
work actually, as soon as the value would not be null.
Change-Id: If9f5b38afa88938db36a795bfc8a403ad660726b
Diffstat (limited to 'core/java/android/widget')
-rw-r--r-- | core/java/android/widget/RelativeLayout.java | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/core/java/android/widget/RelativeLayout.java b/core/java/android/widget/RelativeLayout.java index deec41c..5d6ec1e 100644 --- a/core/java/android/widget/RelativeLayout.java +++ b/core/java/android/widget/RelativeLayout.java @@ -37,7 +37,6 @@ import android.view.Gravity; import android.view.View; import android.view.ViewDebug; import android.view.ViewGroup; -import android.view.WindowManager; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; import android.widget.RemoteViews.RemoteView; @@ -221,13 +220,13 @@ public class RelativeLayout extends ViewGroup { // Some apps came to rely on them. :( private boolean mAllowBrokenMeasureSpecs = false; - private int mDisplayWidth; + // A default width used for RTL measure pass + private static int DEFAULT_WIDTH = Integer.MAX_VALUE / 2; public RelativeLayout(Context context) { super(context); mAllowBrokenMeasureSpecs = context.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.JELLY_BEAN_MR1; - getDisplayWidth(); } public RelativeLayout(Context context, AttributeSet attrs) { @@ -235,7 +234,6 @@ public class RelativeLayout extends ViewGroup { initFromAttributes(context, attrs); mAllowBrokenMeasureSpecs = context.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.JELLY_BEAN_MR1; - getDisplayWidth(); } public RelativeLayout(Context context, AttributeSet attrs, int defStyle) { @@ -243,7 +241,6 @@ public class RelativeLayout extends ViewGroup { initFromAttributes(context, attrs); mAllowBrokenMeasureSpecs = context.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.JELLY_BEAN_MR1; - getDisplayWidth(); } private void initFromAttributes(Context context, AttributeSet attrs) { @@ -253,11 +250,6 @@ public class RelativeLayout extends ViewGroup { a.recycle(); } - private void getDisplayWidth() { - WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); - mDisplayWidth = wm.getDefaultDisplay().getWidth(); - } - @Override public boolean shouldDelayChildPressedState() { return false; @@ -451,12 +443,12 @@ public class RelativeLayout extends ViewGroup { // We need to know our size for doing the correct computation of children positioning in RTL // mode but there is no practical way to get it instead of running the code below. - // So, instead of running the code twice, we just set the width to the "display width" + // So, instead of running the code twice, we just set the width to a "default display width" // before the computation and then, as a last pass, we will update their real position with - // an offset equals to "displayWidth - width". + // an offset equals to "DEFAULT_WIDTH - width". final int layoutDirection = getLayoutDirection(); if (isLayoutRtl() && myWidth == -1) { - myWidth = mDisplayWidth; + myWidth = DEFAULT_WIDTH; } View[] views = mSortedHorizontalChildren; |