It'ss my first time developing an app in a RTL language (Hebrew). I've been struggling for two days with reversed characters.
My String XML:
<resources>
<string name="app_name">SomeApp</string>
<string name="hello_world">מה המצב?</string>
<string name="action_settings">Settings</string>
</resources>
With the string hello_world
I want to create a textView which will use this string. The result should be:
?מה המצב
However the emulator shows:
As you can see its not only change the order of the sentence and the question mark. it also changing the order of the letters.
Things I have tried so far:
\u200F
in begin or end or both of a sentence.\u200e
after each special char like "
, ,
, .
, ?
, !
, etc. When I write in Hebrew without special chars at all everything works fine.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>
I've searched around but nothing works, maybe I missed something.
The screenshot shows not an emulator, but the visual layout manager of Android Studio. This seems to be a weird bug in the layout manager, but it will not effect the application - whether on emulator or on a real device.
You are right, RTL support prior to Android 4.2 was not standardized, and some devices may perform in a strange way. But the emulator even for 2.3.3 does not revert the Hebrew letters for me.
Well, it does not put ?
on the left, and you need to append \u200F
to cure this. But for 4.2 and higher, you can specify android:textDirection="rtl"
instead of the mark.