04 March 2013
Http://android-developers.blogspot.com/2013/03/native-rtl-support-in-android-42.html
HtT
Pandroid-developers.blogspot.com/2013/03/native-rtl-support-in-android-42.html
Native RTL support in Android 4.2.
Posted by Fabrice di meglio, Android frameworks team
Android 4.1 (jelly bean) introduced limited support for Bidirectional text in textview and edittext elements,
Allowing apps to display and edit text in both left-to-right (LTr) and right-to-left (RTL) scripts. Android 4.2 added full
Native support for RTL layouts, including layout locking ing, allowing you to deliver the same great app experience to all of your users, whether their language uses a script that reads right-to-left or one that reads left-to-right.
If you do nothing, your app will not change-it will continue to appear as it currently does. however, with a few simple changes, your app will be automatically mirrored when the user switches the system language to a right-to-left script (such as Arabic,
Hebrew, or Persian). For example, see the following screenshots of the Settings app:
To take advantage of RTL layout locking ing, simply make the following changes to your app:
- Declare in your app manifest that your app supports RTL signing ing.
Specifically, addandroid:supportsRtl="true"
To<application>
Element
In your manifest file.
- Change all of your app's "left/right" layout properties to new "Start/end" equivalents.
- If you are targeting your app to Android 4.2 (the app's
targetSdkVersion
OrminSdkVersion
Is 17 or higher), then you
Shocould use "START" and "end" instead of "left" and "right". For example,android:paddingLeft
Shocould becomeandroid:paddingStart
.
- If you want your app to work with versions earlier than Android 4.2 (the app's
targetSdkVersion
OrminSdkVersion
Is 16 or less ),
Then you shoshould Add "START" and end"In addition"Left" and "right". For example, you 'd use bothandroid:paddingLeft
Andandroid:paddingStart
.
For more precise control over your app UI in both LTR and RTL mode, Android 4.2 includes des the following new APIs to help manage view components:
- Android: layoutdirection-
Attribute for setting the direction of a component's layout.
- Android: textdirection-attribute
For setting the direction of a component's text.
- Android: textalignment-attribute
For setting the alignment of a component's text.
- Getlayoutdirefromlocale ()-
Method for getting the locale-specified direction
You can even create custom versions of layout, drawables, and other resources for display when a right-to-left script is in use. simply use the resource qualifier"ldrtl
"To tag your resources, meaning" layout direction right-to-left ". To debug
And optimize custom right-to-left layouts, hierarchyviewer now lets you see start/end properties, Layout
Direction, text direction, and text alignment for all the views in the hierarchy.
It's now easy to create beautiful Android apps for all your users, whether they use a right-to-left or left-to-right language. we look forward to seeing some great apps!