如何创建一个多语种的Android应用程序从右到左的语言? [英] How can I create a multilingual android application for right to left languages?
问题描述
我已经阅读如何创建一个多语种的Android应用程序和的做Android的支持多国语言?,我知道如何创建一个Android应用程序与多国语言。但我的问题是有关显示为不同的语言从右到左,左到右文本。
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.
例如在英语的TextView
的标签应该是的EditText
的左侧,波斯语,的TextView
应该是右侧的的EditText
。
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
.
我怎么能从右到左的语言和用户界面在我的用户界面支持?
How can I support right to left languages and UIs in my user interface?
我应该设计不同的布局从右到左的语言?我怎么可以指定布局RTL文件夹?像布局-RTL
?或者,我怎么能确定的语言是从右到左?
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?
有没有更简单的方法?
推荐答案
官方支持的Android 4.2引入,看到的 RTL布局支持。您可以查询它是否正在通过<二手href="http://developer.android.com/reference/android/content/res/Configuration.html#SCREENLAYOUT_LAYOUTDIR_RTL"相对=nofollow称号=配置#SCREENLAYOUT_LAYOUTDIR_RTL>此处输入链接的描述。
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.
您可以尝试使用相同的布局在所有情况下,或指定在布局-ldrtl'一个特定的布局。
You can either try and use the same layout in all cases, or specify a specific layout in 'layout-ldrtl'.
根据你的例子,如果你使用的是 RelativeLayout的您需要使用安卓layout_alignParentStart 的属性,而不是安卓layout_alignParentLeft 的从左至右自动改变你的标签。
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.
这篇关于如何创建一个多语种的Android应用程序从右到左的语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!