diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2012-10-01 13:13:12 -0700 |
---|---|---|
committer | Fabrice Di Meglio <fdimeglio@google.com> | 2012-10-01 13:13:12 -0700 |
commit | 80766f1bdf19493bcbd4eae95fcea393c0b7f7ac (patch) | |
tree | 4d435bda7e68b04fb4620773daf75b1a4201051f /core/java | |
parent | 5607e6fbae60fa59bb9fb96d788c52b35e621dde (diff) | |
download | frameworks_base-80766f1bdf19493bcbd4eae95fcea393c0b7f7ac.zip frameworks_base-80766f1bdf19493bcbd4eae95fcea393c0b7f7ac.tar.gz frameworks_base-80766f1bdf19493bcbd4eae95fcea393c0b7f7ac.tar.bz2 |
Fix bug #7259242 text is left justified with no padding
(padding is hard)
- set correct values to mUserPaddingLeftInitial / mUserPaddingRightInitial
- reset padding to initial values depending on layout direction
Change-Id: I5cfb941b4874eafbfcfb5e2926f5a3c80b4931d3
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/view/View.java | 61 |
1 files changed, 42 insertions, 19 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 4b6f4ea..ef75289 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -2881,14 +2881,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * * @hide */ - int mUserPaddingLeftInitial = UNDEFINED_PADDING; + int mUserPaddingLeftInitial = 0; /** * Cache initial right padding. * * @hide */ - int mUserPaddingRightInitial = UNDEFINED_PADDING; + int mUserPaddingRightInitial = 0; /** * Default undefined padding @@ -3643,26 +3643,41 @@ public class View implements Drawable.Callback, KeyEvent.Callback, mUserPaddingRightInitial = padding; } - // RTL compatibility mode: pre Jelly Bean MR1 case OR no RTL support case. - // left / right padding are used if defined (meaning here nothing to do). If they are not - // defined and start / end padding are defined (e.g. in Frameworks resources), then we use - // start / end and resolve them as left / right (layout direction is not taken into account). if (isRtlCompatibilityMode()) { + // RTL compatibility mode: pre Jelly Bean MR1 case OR no RTL support case. + // left / right padding are used if defined (meaning here nothing to do). If they are not + // defined and start / end padding are defined (e.g. in Frameworks resources), then we use + // start / end and resolve them as left / right (layout direction is not taken into account). + // Padding from the background drawable is stored at this point in mUserPaddingLeftInitial + // and mUserPaddingRightInitial) so drawable padding will be used as ultimate default if + // defined. if (!leftPaddingDefined && startPaddingDefined) { leftPadding = startPadding; } + mUserPaddingLeftInitial = (leftPadding > 0) ? leftPadding : 0; if (!rightPaddingDefined && endPaddingDefined) { rightPadding = endPadding; } + mUserPaddingRightInitial = (rightPadding > 0) ? rightPadding : 0; + } else { + // Jelly Bean MR1 and after case: if start/end defined, they will override any left/right + // values defined. Otherwise, left /right values are used. + // Padding from the background drawable is stored at this point in mUserPaddingLeftInitial + // and mUserPaddingRightInitial) so drawable padding will be used as ultimate default if + // defined. + if (startPaddingDefined) { + mUserPaddingLeftInitial = startPadding; + } else if (leftPaddingDefined) { + mUserPaddingLeftInitial = leftPadding; + } + if (endPaddingDefined) { + mUserPaddingRightInitial = endPadding; + } + else if (rightPaddingDefined) { + mUserPaddingRightInitial = rightPadding; + } } - // If the user specified the padding (either with android:padding or - // android:paddingLeft/Top/Right/Bottom), use this padding, otherwise - // use the default padding or the padding from the background drawable - // (stored at this point in mPadding*). Padding resolution will happen later if - // RTL is supported. - mUserPaddingLeftInitial = leftPadding >= 0 ? leftPadding : mPaddingLeft; - mUserPaddingRightInitial = rightPadding >= 0 ? rightPadding : mPaddingRight; internalSetPadding( mUserPaddingLeftInitial, topPadding >= 0 ? topPadding : mPaddingTop, @@ -11745,10 +11760,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, // If start / end padding are not defined, use the left / right ones. int resolvedLayoutDirection = getLayoutDirection(); // Set user padding to initial values ... - mUserPaddingLeft = (mUserPaddingLeftInitial == UNDEFINED_PADDING) ? - 0 : mUserPaddingLeftInitial; - mUserPaddingRight = (mUserPaddingRightInitial == UNDEFINED_PADDING) ? - 0 : mUserPaddingRightInitial; + mUserPaddingLeft = mUserPaddingLeftInitial; + mUserPaddingRight = mUserPaddingRightInitial; // ... then resolve it. switch (resolvedLayoutDirection) { case LAYOUT_DIRECTION_RTL: @@ -14782,8 +14795,18 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * @hide */ public void resetPaddingToInitialValues() { - mPaddingLeft = mUserPaddingLeftInitial; - mPaddingRight = mUserPaddingRightInitial; + if (isRtlCompatibilityMode()) { + mPaddingLeft = mUserPaddingLeftInitial; + mPaddingRight = mUserPaddingRightInitial; + } else { + if (isLayoutRtl()) { + mPaddingLeft = mUserPaddingRightInitial; + mPaddingRight = mUserPaddingLeftInitial; + } else { + mPaddingLeft = mUserPaddingLeftInitial; + mPaddingRight = mUserPaddingRightInitial; + } + } } /** |