简体   繁体   English

TextView中从右到左的文本

[英]Right to Left text in a TextView

I have this string in strings.xml: 我在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: "בא". 当我将TextView的“文本”属性设置为此字符串时,在图形布局中看到的是:“בא”。 (the opposite direction). (相反的方向)。 I have tried using the Unicode 'RIGHT-TO-LEFT MARK'(U+200F), but it doesn't work. 我尝试使用Unicode'RIGHT-TO-LEFT MARK'(U + 200F),但它不起作用。 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. 设置TextView gravity=right这应该控制视图内容的方向,使其与右侧对齐。

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. 然后,当您设置您的文本时,它将在右边标示,并从右到左阅读。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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