Fix for bug 8500202: Right-to-left text not showing in list view
In single line mode, changing the text from LTR to RTL (or vice versa)
affects the alignment, which in turn means that bringTextIntoView is
needed to update the scrolling. A registerForPredraw should be done to
make this happen, but it was missing. This patch tests explicitly for
direction changes in this case, and schedules a predraw if so.
Change-Id: I16e0e23141c244dc8adc00ea8306dfe4c9bf487d
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 52b7a81..1246051 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -5921,6 +5921,11 @@
}
Layout.Alignment alignment = getLayoutAlignment();
+ final boolean testDirChange = mSingleLine && mLayout != null &&
+ (alignment == Layout.Alignment.ALIGN_NORMAL ||
+ alignment == Layout.Alignment.ALIGN_OPPOSITE);
+ int oldDir = 0;
+ if (testDirChange) oldDir = mLayout.getParagraphDirection(0);
boolean shouldEllipsize = mEllipsize != null && getKeyListener() == null;
final boolean switchEllipsize = mEllipsize == TruncateAt.MARQUEE &&
mMarqueeFadeMode != MARQUEE_FADE_NORMAL;
@@ -6009,7 +6014,7 @@
}
}
- if (bringIntoView) {
+ if (bringIntoView || (testDirChange && oldDir != mLayout.getParagraphDirection(0))) {
registerForPreDraw();
}