从右到左的语言

Right to Left Languages

我在我的应用程序中使用 Android Studio 的导航抽屉 Activity,但是当我将系统语言更改为从右到左的语言时,我的应用程序的 UI 会发生变化

Left to right(My main UI)

Right to left

我想在语言更改后保持不变

我能做什么?

如果您的 API 年满 17 岁,您可以使用:android:supportsRtl="true" 在清单中

如果您希望您的观点保持不变,请为 API 级 17+ 设置 android:supportsRtl="false"。并确保您没有使用 startend 作为任何 view.Because 的重力值 startend 用于支持 RTL.Instead 使用的应用程序leftright

如果您希望您的视图根据语言而改变,请设置 android:supportsRtl="true" 并将引力值设置为 startend 而不是 leftright.

注意:开始和结束仅适用于支持 API 级别 17+ 的设备。 有关更多参考,请参阅 This blog

只需在清单中为您的应用程序节点设置 android:supportsRtl="@string/is_rtl" 即可。