【问题标题】:Right-to-Left characters reversed in Android EmulatorAndroid Emulator 中从右到左的字符反转
【发布时间】:2015-10-14 17:49:45
【问题描述】:

这是我第一次用 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的可视化布局管理器。您是否在模拟器中启动了您的应用?

标签: java android-studio unicode android-emulator right-to-left


【解决方案1】:

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

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

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

【讨论】:

  • 找到一个“已关闭”issue。他们似乎只修复了希伯来语字符的大小写问题,但在存在 ? 时却没有。
猜你喜欢
  • 1970-01-01
  • 2018-02-03
  • 2022-01-13
  • 1970-01-01
  • 2020-11-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多