summaryrefslogtreecommitdiff
path: root/core/java/android/widget/RelativeLayout.java
diff options
context:
space:
mode:
authorRomain Guy <romainguy@android.com>2010-01-11 16:46:33 -0800
committerRomain Guy <romainguy@android.com>2010-01-11 16:47:30 -0800
commit42460ac1bb5512a17a6891f7d99e2b45db0889d8 (patch)
treed521674e0b57ae2127782953059a8efc041efe76 /core/java/android/widget/RelativeLayout.java
parent71de7851a2d1c1ef0251bdc1ea59c5e6f58cf429 (diff)
Fix how RelativeLayout handles alignParentBottom/Right when dimension is wrap_content.
Bug: #2194109.
Diffstat (limited to 'core/java/android/widget/RelativeLayout.java')
-rw-r--r--core/java/android/widget/RelativeLayout.java14
1 files changed, 12 insertions, 2 deletions
diff --git a/core/java/android/widget/RelativeLayout.java b/core/java/android/widget/RelativeLayout.java
index fad994b12a0a..1aa1df30afa0 100644
--- a/core/java/android/widget/RelativeLayout.java
+++ b/core/java/android/widget/RelativeLayout.java
@@ -291,6 +291,8 @@ public class RelativeLayout extends ViewGroup {
}
}
+ // TODO: we need to find another way to implement RelativeLayout
+ // This implementation cannot handle every case
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (mDirtyHierarchy) {
@@ -438,6 +440,10 @@ public class RelativeLayout extends ViewGroup {
final int[] rules = params.getRules();
if (rules[CENTER_IN_PARENT] != 0 || rules[CENTER_HORIZONTAL] != 0) {
centerHorizontal(child, params, width);
+ } else if (rules[ALIGN_PARENT_RIGHT] != 0) {
+ final int childWidth = child.getMeasuredWidth();
+ params.mLeft = width - mPaddingRight - childWidth;
+ params.mRight = params.mLeft + childWidth;
}
}
}
@@ -464,6 +470,10 @@ public class RelativeLayout extends ViewGroup {
final int[] rules = params.getRules();
if (rules[CENTER_IN_PARENT] != 0 || rules[CENTER_VERTICAL] != 0) {
centerVertical(child, params, height);
+ } else if (rules[ALIGN_PARENT_BOTTOM] != 0) {
+ final int childHeight = child.getMeasuredHeight();
+ params.mTop = height - mPaddingBottom - childHeight;
+ params.mBottom = params.mTop + childHeight;
}
}
}
@@ -673,7 +683,7 @@ public class RelativeLayout extends ViewGroup {
params.mRight = params.mLeft + child.getMeasuredWidth();
}
}
- return false;
+ return rules[ALIGN_PARENT_RIGHT] != 0;
}
private boolean positionChildVertical(View child, LayoutParams params, int myHeight,
@@ -702,7 +712,7 @@ public class RelativeLayout extends ViewGroup {
params.mBottom = params.mTop + child.getMeasuredHeight();
}
}
- return false;
+ return rules[ALIGN_PARENT_BOTTOM] != 0;
}
private void applyHorizontalSizeRules(LayoutParams childParams, int myWidth) {