diff options
| author | Raph Levien <raph@google.com> | 2013-09-26 15:57:07 -0700 |
|---|---|---|
| committer | Raph Levien <raph@google.com> | 2013-09-26 16:17:11 -0700 |
| commit | 8079ae1a2da32b2720bb14ab9957cc80d77bc139 (patch) | |
| tree | e85bff725e0602413cb66bad86b43b580316c7aa /core/java/android/widget/TextView.java | |
| parent | 373b7a8d4e9dce4f71539d4dbcf627fd3e1a39da (diff) | |
Fix for Text fading on RTL app names is done at the beginning...
This is a fix for bug 10918591 [Android][bidid][HH] "Text fading on RTL
app names is done at the beginning of the text, not at the end."
The old logic for getting the fade edge was not symmetric with respect
to the text direction - when the text was centered, it basically
always placed the fade edge at the left, which of course is appropriate
for LTR text but not RTL. This patch makes the two paths symmetric
and sensitive to text direction.
Change-Id: Ief7604aeb659d474864468d2f102a53f5b43d09e
Diffstat (limited to 'core/java/android/widget/TextView.java')
| -rw-r--r-- | core/java/android/widget/TextView.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index ae1b6279609d..97cb815337c4 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -7838,7 +7838,15 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener getCompoundPaddingLeft() - getCompoundPaddingRight() - mLayout.getLineLeft(0)) / getHorizontalFadingEdgeLength(); case Gravity.CENTER_HORIZONTAL: - return 0.0f; + case Gravity.FILL_HORIZONTAL: + final int textDirection = mLayout.getParagraphDirection(0); + if (textDirection == Layout.DIR_LEFT_TO_RIGHT) { + return 0.0f; + } else { + return (mLayout.getLineRight(0) - (mRight - mLeft) - + getCompoundPaddingLeft() - getCompoundPaddingRight() - + mLayout.getLineLeft(0)) / getHorizontalFadingEdgeLength(); + } } } } @@ -7867,9 +7875,14 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener return 0.0f; case Gravity.CENTER_HORIZONTAL: case Gravity.FILL_HORIZONTAL: - return (mLayout.getLineWidth(0) - ((mRight - mLeft) - + final int textDirection = mLayout.getParagraphDirection(0); + if (textDirection == Layout.DIR_RIGHT_TO_LEFT) { + return 0.0f; + } else { + return (mLayout.getLineWidth(0) - ((mRight - mLeft) - getCompoundPaddingLeft() - getCompoundPaddingRight())) / getHorizontalFadingEdgeLength(); + } } } } |
