我正在制作一个将使用阿拉伯语 (RTL) 和英语 (LTR) 的 Android 应用程序,用户可以从该应用程序在 RTL 和 LTR 之间切换。我是否必须为两种不同的设计制作 xml 文件,这听起来不是个好主意。 有很多 TextView 和单选按钮,我不想分别对齐它们,那么我应该怎么做的建议是什么?
最佳答案
在阿拉伯语 (/res/Layout-ar) 中创建 xml 和在 XML (/res/Layout) 中创建另一个 xml 以及在 drawable 中创建相同的值时,您可以做到这一点。我认为这是创建多语言应用程序的完美方法。
您可以自定义 textview 和单选按钮,.....从写 gravity = right if its arabic 开始
阿拉伯语单选按钮示例:
<RadioButton
android:id="@+id/radio1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:button="@drawable/radiobutton_selector"
android:gravity="right" />
关于android - 在android中的RTL和LTR之间切换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17941897/