summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Fabrice Di Meglio <fdimeglio@google.com> 2012-09-18 10:47:06 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2012-09-18 10:47:07 -0700
commitb250e94fdced2bd753eeb75f378abfab8b17cc2c (patch)
tree6bed67bd7796366d27696aec99355c3a6b762070
parenta4b0e5590dc303df68256254f732ef632e6912f3 (diff)
parent0762cec04fa5ce65a2adc6d70ea1396041b1a88d (diff)
Merge "Fix bug #7112174 ActionMenuView should be aware of layout direction" into jb-mr1-dev
-rw-r--r--core/java/com/android/internal/view/menu/ActionMenuView.java54
1 files changed, 40 insertions, 14 deletions
diff --git a/core/java/com/android/internal/view/menu/ActionMenuView.java b/core/java/com/android/internal/view/menu/ActionMenuView.java
index dc4ee3ae231a..34ade74c9d29 100644
--- a/core/java/com/android/internal/view/menu/ActionMenuView.java
+++ b/core/java/com/android/internal/view/menu/ActionMenuView.java
@@ -400,6 +400,7 @@ public class ActionMenuView extends LinearLayout implements MenuBuilder.ItemInvo
int nonOverflowCount = 0;
int widthRemaining = right - left - getPaddingRight() - getPaddingLeft();
boolean hasOverflow = false;
+ final boolean isLayoutRtl = isLayoutRtl();
for (int i = 0; i < childCount; i++) {
final View v = getChildAt(i);
if (v.getVisibility() == GONE) {
@@ -414,8 +415,15 @@ public class ActionMenuView extends LinearLayout implements MenuBuilder.ItemInvo
}
int height = v.getMeasuredHeight();
- int r = getWidth() - getPaddingRight() - p.rightMargin;
- int l = r - overflowWidth;
+ int r;
+ int l;
+ if (isLayoutRtl) {
+ l = getPaddingLeft() + p.leftMargin;
+ r = l + overflowWidth;
+ } else {
+ r = getWidth() - getPaddingRight() - p.rightMargin;
+ l = r - overflowWidth;
+ }
int t = midVertical - (height / 2);
int b = t + height;
v.layout(l, t, r, b);
@@ -448,20 +456,38 @@ public class ActionMenuView extends LinearLayout implements MenuBuilder.ItemInvo
final int spacerCount = nonOverflowCount - (hasOverflow ? 0 : 1);
final int spacerSize = Math.max(0, spacerCount > 0 ? widthRemaining / spacerCount : 0);
- int startLeft = getPaddingLeft();
- for (int i = 0; i < childCount; i++) {
- final View v = getChildAt(i);
- final LayoutParams lp = (LayoutParams) v.getLayoutParams();
- if (v.getVisibility() == GONE || lp.isOverflowButton) {
- continue;
+ if (isLayoutRtl) {
+ int startRight = getWidth() - getPaddingRight();
+ for (int i = 0; i < childCount; i++) {
+ final View v = getChildAt(i);
+ final LayoutParams lp = (LayoutParams) v.getLayoutParams();
+ if (v.getVisibility() == GONE || lp.isOverflowButton) {
+ continue;
+ }
+
+ startRight -= lp.rightMargin;
+ int width = v.getMeasuredWidth();
+ int height = v.getMeasuredHeight();
+ int t = midVertical - height / 2;
+ v.layout(startRight - width, t, startRight, t + height);
+ startRight -= width + lp.leftMargin + spacerSize;
}
+ } else {
+ int startLeft = getPaddingLeft();
+ for (int i = 0; i < childCount; i++) {
+ final View v = getChildAt(i);
+ final LayoutParams lp = (LayoutParams) v.getLayoutParams();
+ if (v.getVisibility() == GONE || lp.isOverflowButton) {
+ continue;
+ }
- startLeft += lp.leftMargin;
- int width = v.getMeasuredWidth();
- int height = v.getMeasuredHeight();
- int t = midVertical - height / 2;
- v.layout(startLeft, t, startLeft + width, t + height);
- startLeft += width + lp.rightMargin + spacerSize;
+ startLeft += lp.leftMargin;
+ int width = v.getMeasuredWidth();
+ int height = v.getMeasuredHeight();
+ int t = midVertical - height / 2;
+ v.layout(startLeft, t, startLeft + width, t + height);
+ startLeft += width + lp.rightMargin + spacerSize;
+ }
}
}