RTL Languages support in android and resource qualifiers

此生再无相见时 提交于 2019-11-27 18:38:44

问题


I read this sentence " Android 2.3 added support for right-to-left (RTL) languages" and now I want to add RTL support to my app. But I do not know what is qualifiers to add to my layouts.

About res/values/strings.xml , I can named like this res/values-ar/strings.xml

I want to have different layout for RLT languages. I do not want to have just different strings , I also want different layout. What the layout folder name should look like ?

At this moment for the left to right languages it is named res/lauyots/main.xml but I do not know how to name it for RTL languages

Is this kind qualifier is present at all ?


回答1:


@Silwek is right. This is his answer, I am merely putting it here because my answer has been marked as answered.

res/layout-ldltr/ (Left to Right, default value)
res/layout-ldrtl/ (Right to Left)

Old Answer

Check Localization and Multiple Screen Support, they give you idea about resource folders and qualifiers.

You can use locale specific resources and layout like this:

For language specific resources:

res/values/strings.xml
res/values-fr/strings.xml (French)
res/values-ja/strings.xml (Japanese)

For language specific layouts:

res/layout-fr/main.xml
res/layout-ar/main.xml



回答2:


You can find -ldrtl and -ldltr qualifiers in Providing resources

res/layout-ldltr/ (Left to Right, default value)
res/layout-ldrtl/ (Right to Left)



回答3:


Using rtl with resources is not a correct approach .. you missed that Devices with RTL locale such Arabic,Hebrew, Persian ... usually enforce all apps ( even with english language only ) to use rtl as language direction and text direction... and here where its dangerous to use rtl in resources because you will cause using your RTL layout for all languages for RTL Locale device. Better to track languages.



来源:https://stackoverflow.com/questions/7420127/rtl-languages-support-in-android-and-resource-qualifiers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!