在 Eclipse list 文件中,我收到一条警告消息。应用语言是土耳其语(不是从右到左)。
“项目引用了 RTL 属性,但没有在 manifest 中使用 android:supportsRtl 显式启用或禁用 RTL 支持”
我无法添加 android:supportsRtl 行,因为我的 min sdk versionn 是 9。 这个警告很重要吗?
谢谢
最佳答案
如果您不支持 RTL(= 从右到左语言环境),您需要将所有 start 的引用替换为 left 和 end由 right 在您的 xml 布局中。
属性“start”、“end”、“paddingStart”、“paddingEnd”、“android:layout_alignParentStart”等是“RTL 属性”:它们的含义取决于当前的语言环境。不这样做的风险是,如果有人将他们的系统语言设置为阿拉伯语或希伯来语,您的布局将被镜像,即使文本仍以土耳其语显示。
具体来说,“开始”意味着“正确”,如果:
- 当前系统语言是 RTL(阿拉伯语、希伯来语...)
- Android 设备是 API 17 或更高版本
- 并且 android:supportsRtl 在 list 中设置为 true
否则就是“左”的意思。
因此,如果您在任何布局中使用了 android:layout_gravity="start" 或任何 start/end 属性并且您没有设置 android:supportsRtl="true" 在 list 中。
请注意,如果您的 min SDK 为 16 或以下并且您不想支持 RTL,您实际上必须选择警告之一:
- 如果您将 start 替换为 left,您将收到警告:使用“start”而不是“left”以确保在从右到左的语言环境中行为正确 Id=RtlHardCoded
- 如果您将 android:supportsRtl 设置为 false:属性“supportsRtl”仅用于 API 级别 17 及更高级别(当前最低为 9)强>。 Id=UnusedAttribute
- 否则:** 项目引用 RTL 属性,但未在 list 中使用 android:supportsRtl 显式启用或禁用 RTL 支持** Id=RtlEnabled
如果您不支持 RTL,将 RtlHardCoded 设置为 Info 而不是警告似乎是合乎逻辑的。
更多信息:
http://developer.android.com/guide/topics/manifest/application-element.html#supportsrtl
关于android - 该项目引用 RTL 属性,但未明确启用或禁用 RTL 支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27378921/