summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
authorFabrice Di Meglio <fdimeglio@google.com>2011-06-01 15:13:50 -0700
committerFabrice Di Meglio <fdimeglio@google.com>2011-06-01 16:46:25 -0700
commitde35ceeeb9f8855c72dfd70593e917aa75b43770 (patch)
treea4403767af1beae19a8c850e248291fd91b1face /core/java/android
parent0d8f66f08db97885dc295e1a22c2cba5645bbf10 (diff)
downloadframeworks_base-de35ceeeb9f8855c72dfd70593e917aa75b43770.zip
frameworks_base-de35ceeeb9f8855c72dfd70593e917aa75b43770.tar.gz
frameworks_base-de35ceeeb9f8855c72dfd70593e917aa75b43770.tar.bz2
Fix bug #4509967 (layout_gravity not always respected)
- fix FrameLayout - code refactoring on LinearLayout - add more unit tests Change-Id: I49302582c61aa31a4eb7eded92327b10408f71a4
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/widget/FrameLayout.java10
-rw-r--r--core/java/android/widget/LinearLayout.java4
2 files changed, 7 insertions, 7 deletions
diff --git a/core/java/android/widget/FrameLayout.java b/core/java/android/widget/FrameLayout.java
index 2a1398d..4ee16e7 100644
--- a/core/java/android/widget/FrameLayout.java
+++ b/core/java/android/widget/FrameLayout.java
@@ -16,6 +16,8 @@
package android.widget;
+import java.util.ArrayList;
+
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
@@ -23,14 +25,12 @@ import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
+import android.view.Gravity;
import android.view.View;
import android.view.ViewDebug;
import android.view.ViewGroup;
-import android.view.Gravity;
import android.widget.RemoteViews.RemoteView;
-import java.util.ArrayList;
-
/**
* FrameLayout is designed to block out an area on the screen to display
@@ -364,10 +364,10 @@ public class FrameLayout extends ViewGroup {
gravity = DEFAULT_CHILD_GRAVITY;
}
- final int horizontalGravity = Gravity.getAbsoluteGravity(gravity, isLayoutRtl());
+ final int absoluteGravity = Gravity.getAbsoluteGravity(gravity, isLayoutRtl());
final int verticalGravity = gravity & Gravity.VERTICAL_GRAVITY_MASK;
- switch (horizontalGravity) {
+ switch (absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
case Gravity.LEFT:
childLeft = parentLeft + lp.leftMargin;
break;
diff --git a/core/java/android/widget/LinearLayout.java b/core/java/android/widget/LinearLayout.java
index 8d449e0..298fe00 100644
--- a/core/java/android/widget/LinearLayout.java
+++ b/core/java/android/widget/LinearLayout.java
@@ -1430,8 +1430,8 @@ public class LinearLayout extends ViewGroup {
if (gravity < 0) {
gravity = minorGravity;
}
- gravity = Gravity.getAbsoluteGravity(gravity, isLayoutRtl());
- switch (gravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
+ final int absoluteGravity = Gravity.getAbsoluteGravity(gravity, isLayoutRtl());
+ switch (absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
case Gravity.CENTER_HORIZONTAL:
childLeft = paddingLeft + ((childSpace - childWidth) / 2)
+ lp.leftMargin - lp.rightMargin;