在 android Studio 的约束布局中支持 RTL 的最佳实践是什么,
或者我应该创建一个单独的布局,一个用于英语,另一个用于阿拉伯语?
英文版
The Expected layout with Arabic language
The output layout when I change the Device Language from English to Arabic
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="@string/CourseName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView7"
android:layout_marginTop="16dp"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginStart="16dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginLeft="16dp"
android:textAppearance="@style/TextAppearance.AppCompat.Display1" />
<Button
android:text="@string/enroll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button"
android:layout_marginTop="16dp"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginEnd="16dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginRight="16dp"
android:textAppearance="@style/TextAppearance.AppCompat.Display2" />
</android.support.constraint.ConstraintLayout>
正如 CommonsWare 已经指出的,你应该很少/从不如果您计划支持 RTL 语言,特别是如果您的目标是 API 16+,请使用 Left/Right。
更换你的app:layout_constraintRight_toRightOf="parent"
with app:layout_constraintEnd_toEndOf="parent"
等等。
结束为右,开始为左。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)