Question

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 here enter 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?

Was it helpful?

Solution

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.

OTHER TIPS

You can create a list of words that are not translatable, so that you know that calling those resources it will get always the same languages. For example:

<string name="english">English</string>
<string name="english_fixed" translatable="false">English </string>

In this case the reference to R.string.english_fixed will always display the same string while R.string.english will translate the word. Then, you can use the two different resources in two different TextViews, on the left and on the right.

Did I understand the question?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top