Android 设置与 TextView 的希伯来语文本? [英] Android setting with TextView for Hebrew text?

查看:29
本文介绍了Android 设置与 TextView 的希伯来语文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过字符串资源在 TextView 中设置文本.通常,希伯来语以从右到左的格式工作.当我设置文本时,它会在 LG、三星、索尼手机中设置文本从右到左的格式,但在 HTC 中它不起作用.它在 HTC 中以从左到右的格式工作.即使我将 Gravity 设置为 Java 文件中的 TextView.

I am setting text in TextView from string resource. Normally, Hebrew works in Right-To-Left format. When I set a text, it sets the text Right-To-Left format in LG, Samsung, Sony Phone but in HTC it does not work. It works in Left-To-Right format in HTC. Even I set Gravity to the TextView in Java file.

TextView 中的文本应根据屏幕大小而跨度.例如,如果是 320 x 480,则显示为 4 行,但如果是 Galaxy Tab,则可能有 2 行.

Text in TextView should be span according to the screen size. For example if it is 320 x 480 then it display in 4 lines but if it is Galaxy Tab then there may be 2 lines.

这是我的代码片段:

在 Java 中:

private TextView mVersionInfo, mVersionDescriptionOne, mVersionDescriptionTwo, mVersionDescriptionThree;

mVersionInfo = (TextView)findViewById(R.id.VersionInfo);
mVersionDescriptionOne = (TextView)findViewById(R.id.VersionDesc1);
mVersionDescriptionTwo = (TextView)findViewById(R.id.VersionDesc2);
mVersionDescriptionThree = (TextView)findViewById(R.id.VersionDesc3);

mVersionDescriptionOne.setGravity(Gravity.RIGHT);
mVersionDescriptionTwo.setGravity(Gravity.RIGHT);
mVersionDescriptionThree.setGravity(Gravity.RIGHT);

在 XML 中:

<TextView android:id="@+id/VersionDesc1"
        android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:text="@string/versiondesc1" android:textColor="#000000"
        android:layout_marginTop="5dip" android:gravity="right"
        android:layout_alignParentRight="true" android:layout_marginRight="10dip"
        android:layout_below="@+id/Share" android:textSize="13sp"
        android:layout_alignRight="@+id/Body" />
    <TextView android:id="@+id/VersionDesc2"
        android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:text="@string/versiondesc2" android:textColor="#000000"
        android:layout_alignParentRight="true" android:layout_marginRight="10dip"
        android:layout_below="@+id/VersionDesc1" android:textSize="13sp"
        android:layout_marginTop="5dip" android:gravity="right"
        android:layout_alignRight="@+id/Body" />
    <TextView android:id="@+id/VersionDesc3"
        android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:text="@string/versiondesc3" android:textColor="#000000"
        android:layout_alignParentRight="true" android:layout_marginRight="10dip"
        android:layout_below="@+id/VersionDesc2" android:textSize="13sp"
        android:layout_marginTop="5dip" android:gravity="right"
        android:layout_alignRight="@+id/Body" />

在字符串资源中:

<string name="versiondesc1">האפליקציה מתחברת לאתר הספק הסלולרי כדי להציג את מצב החשבון. לעיתים, כשאתר הספק איננו עובד תקין לא יהיה ניתן לקבל מידע. באם אתר הספק ישתנה האפליקציה עלולה להפסיק לעבוד. במצב כזה האפליקציה תחזור לעבודה תקינה מיד לאחר שאנו נתאים את שרת התוכנה שלנו לשינויים.</string>
<string name="versiondesc2">הערה: אנחנו לא מייצגים את חברות הסלולר ולא נמצאים איתן בקשר מסוג כלשהו!</string>
<string name="versiondesc3">אם נתקלת בבעיה, השתמש/י בכפתור יצירת קשר על מנת שנוכל לפתור אותה. נשמח לקבל כל משוב על האפליקציה.</string>

我的代码有什么问题?

任何使用过其他语言的人,请在这里指导我.

Anybody who has worked with another language, Please guide me here.

谢谢.

推荐答案

重力只会影响对齐,不会设置文本的基本方向.它适用于某些设备而不适用于其他设备可能是字体问题,或者可能是操作系统版本问题.尝试在文本开头添加 RIGHT-TO-LEFT MARK 字符 (u200F).这可能有助于 HTC 上的显示,并且不会损害已经工作的设备上的任何东西.

Gravity will only affect alignment and will not set base direction for the text. That it works on some devices and not others may be a font issue, or perhaps an OS version issue. Try adding a RIGHT-TO-LEFT MARK character (u200F) at the start of your text. This might help the display on an HTC and will not hurt anything on devices where it is already working.

这篇关于Android 设置与 TextView 的希伯来语文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆