summaryrefslogtreecommitdiffstats
path: root/core/java/android/widget/RelativeLayout.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/widget/RelativeLayout.java')
-rw-r--r--core/java/android/widget/RelativeLayout.java18
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;