Android 模拟器中从右到左的字符反转

Right-to-Left characters reversed in Android Emulator

这是我第一次使用 RTL 语言(希伯来语)开发应用程序。被颠倒的字符折腾了两天

我的字符串XML:

<resources>
   <string name="app_name">SomeApp</string>

   <string name="hello_world">מה המצב?</string>
   <string name="action_settings">Settings</string>
</resources>

使用字符串 hello_world 我想创建一个将使用该字符串的 textView。结果应该是:

?מה המצב

但是模拟器显示:

如您所见,它不仅改变了句子和问号的顺序。它还改变了字母的顺序。

到目前为止我尝试过的事情:

  1. API 20级及以上。有些地方暗示这个问题在4.2版本之后被修复了。
  2. 在句子的开头或结尾或两者都使用标记 \u200F
  3. 在每个特殊字符后使用 \u200e,例如 ",.?! 等。当我用希伯来语书写,完全没有特殊字符,一切正常。

activity_my.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"        android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MyActivity"
android:id="@+id/StudentLife">

<TextView android:text="@string/hello_world"             android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/textView"
    android:layout_alignParentTop="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true" />

   </RelativeLayout>

我四处搜索但没有任何效果,也许我遗漏了什么。

屏幕截图显示的不是模拟器,而是 Android Studio 的可视化布局管理器。这似乎是布局管理器中的一个奇怪错误,但它不会影响应用程序 - 无论是在模拟器上还是在真实设备上。

你是对的,Android 4.2 之前的 RTL 支持没有标准化,一些设备可能以奇怪的方式运行。但是即使是 2.3.3 的模拟器也不会为我恢复希伯来字母。

嗯,它没有把?放在左边,你需要追加\u200F来解决这个问题。但对于 4.2 及更高版本,您可以指定 android:textDirection="rtl" 而不是标记