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

有帮助吗?

解决方案

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);
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top