Question

I would like my marquee to move from right to left when it contains a text in a left-to-right locale (like western languages), and left to right when it contains right-to-left locale (like hebrew or arabic). I found other questions bout textview marquee direction, with all kinds of hacks but without the connection to the locale writing. Normally this should be filed as a bug to Google...

Was it helpful?

Solution

You can check if the user's language is RTL or not. There is different ways to achieve this. It looks like BidiFormatter added recently in the Compatibility Package looks like a simple option. You can then set the marquee programatically with setEllipsize

It should look something like this :

if (bidiFormatter.isRtlContext()) {
   textView.setEllipsize(TextUtils.TruncateAt.BEGIN);
} else {
   textView.setEllipsize(TextUtils.TruncateAt.END);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top