【问题标题】:Setting right-to-left direction for Hebrew in an android app在android应用程序中为希伯来语设置从右到左的方向
【发布时间】:2012-09-27 18:09:21
【问题描述】:

我用希伯来语写了一个应用程序,但是单词的方向有问题:

这是代码:

textView2.setText("יצרן: " + company + "\n");
textView2.append("דגם: " + degem + "\n");
textView2.append("מנוע: " + manoa + "\n");
textView2.append("ק'מ/ליטר: "+  watt + "\n");
textView2.append("נסיעה: " + timeString + " " + timeMedida+"\n");

我明白了:

地主:阿巴特

而不是

阿巴特:יצרן

דגם:005

而不是

דגם:500

xml:

<TextView
    android:id="@+id/txt_1_delek"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
            android:gravity="center"


    android:layout_marginTop="50sp"
    android:layout_marginRight="100sp"
    android:layout_marginLeft="100sp"
    android:text="myTextView"/>

【问题讨论】:

标签: android hebrew right-to-left


【解决方案1】:

如果有人偶然发现这个老问题并正在寻找答案... Amir 的链接指向正确的方向。 您需要的是更改文本的基本方向(而不是对齐方式,因此如链接“gravity.RIGHT”中所述,不会有帮助)。在字符串的开头插入“左标记”unicode 字符 \u200F 就可以了。

顺便说一句,只是将它添加为硬编码字符对我不起作用,显然是因为编码问题。我宁愿避免在代码中处理它,所以我只是从 strings.xml 中将字符提取为字符串,让 android 根据需要进行转换,然后附加字符串(在你的情况下为“יצרן:”+ company+“ \n") 实时。

【讨论】:

    猜你喜欢
    • 2011-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多