Search code examples
androidarabic

Android Arabic text alignment


I use class from How to support Arabic text in Android? to show Arabic text. In Android 2.1 - 2.3 text located in the left side, so I use android:gravity="right", but in Android 3.0+ Arabic text has automatically alignment in right side and if I use android:gravity="right" in will be alignment in the left side. How can I make the text to be aligned with the same in different Android versions?


Solution

  • You can create different versions of the layouts for different API versions.

    As you can read here: http://developer.android.com/guide/topics/resources/providing-resources.html you can have say the normal folder (/res/layout/) with the layout for old devices and then another one for the ones that support it: /res/layout-11/

    The layout inside layout-v11 will only be applied on devices with android 3.0 and over.

    Hope it helps. (UPD: API level changed to 11)

    UPDATE

    On Android 4.2 This is a native feature :)

    http://android-developers.blogspot.com.es/2013/03/native-rtl-support-in-android-42.html