简体   繁体   中英

Right to Left text in a TextView

I have this string in strings.xml:

<string name="mystring">אב</string>

when I set the "text" propety of a TextView to this string, what I see in the Graphical Layout is this: "בא". (the opposite direction). I have tried using the Unicode 'RIGHT-TO-LEFT MARK'(U+200F), but it doesn't work. I still get "בא" instead of "אב".

Any ideas?

Set the TextView to have gravity=right this should control the orientation of the contents of the view so it aligns to the right side.

Then reverse the order of the string so it reads right to left. You can use an approach similar to this to reverse the string where you iterate over the string and just append the characters together in reverse order.

Then when you set your text it will be alligned to the right and read right to left.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM