diff options
author | Philip Milne <pmilne@google.com> | 2012-09-27 14:38:46 -0700 |
---|---|---|
committer | Philip Milne <pmilne@google.com> | 2012-09-27 14:46:36 -0700 |
commit | ad365cc217c989c3b688ae839d6f94ee8889a84e (patch) | |
tree | d238148b698d57c315654942acefc3339f1bb28b /core/java/android/widget | |
parent | 3cc8211ecd61c8568f182de5fb615d880e889ff9 (diff) | |
download | frameworks_base-ad365cc217c989c3b688ae839d6f94ee8889a84e.zip frameworks_base-ad365cc217c989c3b688ae839d6f94ee8889a84e.tar.gz frameworks_base-ad365cc217c989c3b688ae839d6f94ee8889a84e.tar.bz2 |
Optical bounds support for LinearLayout, TableLayout and TableRow.
The generic support for optical bounds provided in:
https://googleplex-android-review.googlesource.com/#/c/228269/
did not work correctly for nested LinearLayouts. With this fix
all the layouts in the APIdemos now seem to layout correctly
when the optical bounds mode is enabled.
(There's currently no, user level, way to do this. Instead, the
optical bounds layout mode has to be enabled on a per view basis.)
Change-Id: Id3d1d84445a8a2df277ddfe679c42f2d6cf775f4
Diffstat (limited to 'core/java/android/widget')
-rw-r--r-- | core/java/android/widget/LinearLayout.java | 28 | ||||
-rw-r--r-- | core/java/android/widget/TableLayout.java | 2 | ||||
-rw-r--r-- | core/java/android/widget/TableRow.java | 2 |
3 files changed, 20 insertions, 12 deletions
diff --git a/core/java/android/widget/LinearLayout.java b/core/java/android/widget/LinearLayout.java index b6f0862..ea8ee79 100644 --- a/core/java/android/widget/LinearLayout.java +++ b/core/java/android/widget/LinearLayout.java @@ -1431,9 +1431,9 @@ public class LinearLayout extends ViewGroup { @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { if (mOrientation == VERTICAL) { - layoutVertical(); + layoutVertical(l, t, r, b); } else { - layoutHorizontal(); + layoutHorizontal(l, t, r, b); } } @@ -1444,15 +1444,19 @@ public class LinearLayout extends ViewGroup { * @see #getOrientation() * @see #setOrientation(int) * @see #onLayout(boolean, int, int, int, int) + * @param left + * @param top + * @param right + * @param bottom */ - void layoutVertical() { + void layoutVertical(int left, int top, int right, int bottom) { final int paddingLeft = mPaddingLeft; int childTop; int childLeft; // Where right end of child should go - final int width = mRight - mLeft; + final int width = right - left; int childRight = width - mPaddingRight; // Space available for child @@ -1466,12 +1470,12 @@ public class LinearLayout extends ViewGroup { switch (majorGravity) { case Gravity.BOTTOM: // mTotalLength contains the padding already - childTop = mPaddingTop + mBottom - mTop - mTotalLength; + childTop = mPaddingTop + bottom - top - mTotalLength; break; // mTotalLength contains the padding already case Gravity.CENTER_VERTICAL: - childTop = mPaddingTop + (mBottom - mTop - mTotalLength) / 2; + childTop = mPaddingTop + (bottom - top - mTotalLength) / 2; break; case Gravity.TOP: @@ -1534,8 +1538,12 @@ public class LinearLayout extends ViewGroup { * @see #getOrientation() * @see #setOrientation(int) * @see #onLayout(boolean, int, int, int, int) + * @param left + * @param top + * @param right + * @param bottom */ - void layoutHorizontal() { + void layoutHorizontal(int left, int top, int right, int bottom) { final boolean isLayoutRtl = isLayoutRtl(); final int paddingTop = mPaddingTop; @@ -1543,7 +1551,7 @@ public class LinearLayout extends ViewGroup { int childLeft; // Where bottom of child should go - final int height = mBottom - mTop; + final int height = bottom - top; int childBottom = height - mPaddingBottom; // Space available for child @@ -1563,12 +1571,12 @@ public class LinearLayout extends ViewGroup { switch (Gravity.getAbsoluteGravity(majorGravity, layoutDirection)) { case Gravity.RIGHT: // mTotalLength contains the padding already - childLeft = mPaddingLeft + mRight - mLeft - mTotalLength; + childLeft = mPaddingLeft + right - left - mTotalLength; break; case Gravity.CENTER_HORIZONTAL: // mTotalLength contains the padding already - childLeft = mPaddingLeft + (mRight - mLeft - mTotalLength) / 2; + childLeft = mPaddingLeft + (right - left - mTotalLength) / 2; break; case Gravity.LEFT: diff --git a/core/java/android/widget/TableLayout.java b/core/java/android/widget/TableLayout.java index 113299a..b65b421 100644 --- a/core/java/android/widget/TableLayout.java +++ b/core/java/android/widget/TableLayout.java @@ -445,7 +445,7 @@ public class TableLayout extends LinearLayout { @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { // enforce vertical layout - layoutVertical(); + layoutVertical(l, t, r, b); } /** diff --git a/core/java/android/widget/TableRow.java b/core/java/android/widget/TableRow.java index db3853f..a1527d5 100644 --- a/core/java/android/widget/TableRow.java +++ b/core/java/android/widget/TableRow.java @@ -120,7 +120,7 @@ public class TableRow extends LinearLayout { @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { // enforce horizontal layout - layoutHorizontal(); + layoutHorizontal(l, t, r, b); } /** |