Android : ConstraintLayout 支持 RTL
Android : ConstraintLayout support RTL
我经历了很多解决方案,但我不明白如何在 android 中使用 ConstraintLayout
为 RTL 提供设计支持。
只需将约束从 Left
替换为 Start
& Right
到 End
,
app:layout_constraintLeft_toRightOf = layout_constraintStart_toEndOf
app:layout_constraintRight_toLeftOf = layout_constraintEnd_toStartOf
app:layout_constraintLeft_toLeftOf = layout_constraintStart_toStartOf
app:layout_constraintRight_toRightOf = layout_constraintEnd_toEndOf
我相信它会非常适合你,
看我的范式 item_list.xml
LTR 截图
RTL 截图
注意: 我希望你已经在 AndroidManifest.xml
中添加了这一行 android:supportsRtl="true"
& 有些地方你需要删除 textAlignment 属性。对齐肯定适用于 阿拉伯语 文本。
更新:
It's better practices to add/put both properties to avoid api level version support,
layout_constraintLeft_toRightOf
layout_constraintStart_toEndOf
layout_constraintRight_toLeftOf
layout_constraintEnd_toStartOf
layout_constraintLeft_toLeftOf
layout_constraintStart_toStartOf
layout_constraintRight_toRightOf
layout_constraintEnd_toEndOf
做以下事情,
- 查找
Left
并将其替换为 Start
- 查找
Right
并将其替换为 End
如果您使用的是leftDrawing
或rightDrawing
,仍然需要将其替换为startDrawing
& endDrawing
填充也一样,
并且不要忘记在 AndroidManifest
文件中添加以下行,
android:supportsRtl="true"
我经历了很多解决方案,但我不明白如何在 android 中使用 ConstraintLayout
为 RTL 提供设计支持。
只需将约束从 Left
替换为 Start
& Right
到 End
,
app:layout_constraintLeft_toRightOf = layout_constraintStart_toEndOf
app:layout_constraintRight_toLeftOf = layout_constraintEnd_toStartOf
app:layout_constraintLeft_toLeftOf = layout_constraintStart_toStartOf
app:layout_constraintRight_toRightOf = layout_constraintEnd_toEndOf
我相信它会非常适合你,
看我的范式 item_list.xml
LTR 截图
RTL 截图
注意: 我希望你已经在 AndroidManifest.xml
中添加了这一行 android:supportsRtl="true"
& 有些地方你需要删除 textAlignment 属性。对齐肯定适用于 阿拉伯语 文本。
更新:
It's better practices to add/put both properties to avoid api level version support,
layout_constraintLeft_toRightOf
layout_constraintStart_toEndOf
layout_constraintRight_toLeftOf
layout_constraintEnd_toStartOf
layout_constraintLeft_toLeftOf
layout_constraintStart_toStartOf
layout_constraintRight_toRightOf
layout_constraintEnd_toEndOf
做以下事情,
- 查找
Left
并将其替换为Start
- 查找
Right
并将其替换为End
如果您使用的是leftDrawing
或rightDrawing
,仍然需要将其替换为startDrawing
& endDrawing
填充也一样,
并且不要忘记在 AndroidManifest
文件中添加以下行,
android:supportsRtl="true"