Mic
Mic

Reputation: 357

Android: how to move marquee in the same direction as the text

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...

Upvotes: 0

Views: 1268

Answers (1)

ben
ben

Reputation: 1161

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);
}

Upvotes: 2

Related Questions