Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create a multilingual android application for right to left languages?

I have read How can I create a multilingual android application? and Do android support multiple languages? and I know about creating an android application with multiple languages. But my problem is about showing right-to-left and left-to-right texts for different languages.

For example in English a TextView as label should be on the left side of EditText and in Persian, TextView should be on the right side of EditText.

enter image description hereenter image description here

How can I support right to left languages and UIs in my user interface?

Should I design different layouts for right to left languages? How can I specify a folder in layouts for RTL? something like layout-rtl? Or how can I determine the language is right to left?

Is there any easier way?

like image 401
Bobs Avatar asked Oct 08 '13 12:10

Bobs


1 Answers

Official support was introduced in Android 4.2, see RTL Layout Support. You can query whether it is being used through enter link description here.

You can either try and use the same layout in all cases, or specify a specific layout in 'layout-ldrtl'.

As per your example, if you're using the RelativeLayout you need to use the android:layout_alignParentStart attribute, rather than the android:layout_alignParentLeft to shift your label from left to right automatically.

like image 138
Richard Taylor Avatar answered Oct 12 '22 08:10

Richard Taylor