eclipse 项目引用 RTL 属性,但未明确启用或禁用 RTL 支持

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27378921/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 22:17:02  来源:igfitidea点击:

The project references RTL attributes, but does not explicitly enable or disable RTL support

androideclipsewarningsright-to-left

提问by manowar_manowar

In Eclipse manifest file , i get a warning message. Application language is Turkish ( Not right to left ).

在 Eclipse 清单文件中,我收到一条警告消息。应用程序语言是土耳其语(不是从右到左)。

"The project references RTL attributes, but does not explicitly enable or disable RTL support with android:supportsRtl in the manifest "

“该项目引用了 RTL 属性,但未在清单中使用 android:supportsRtl 显式启用或禁用 RTL 支持”

I can not add android:supportsRtlline, because my min sdk versionn is 9. This warning is important?

我不能添加android:supportsRtl行,因为我的最小 sdk versionn 是 9。这个警告​​很重要吗?

Thanks

谢谢

回答by BenL

If you do not support RTL (= Right To Left locales), you need to replace all references of startby leftand endby rightin your xml layouts.

如果你不支持RTL(=从右到左的语言环境),则需要更换的所有引用开始最终通过在你的XML布局。

The attributes "start", "end", "paddingStart", "paddingEnd", "android:layout_alignParentStart" etc.. are "RTL attributes" : their meaning depends on the current locale. The risk of not doing this is that if someone sets their system language to Arabic or Hebrew your layouts will be mirrored, even if the text is still displayed in Turkish.

属性“start”、“end”、“paddingStart”、“paddingEnd”、“android:layout_alignParentStart”等是“RTL 属性”:它们的含义取决于当前的语言环境。不这样做的风险是,如果有人将他们的系统语言设置为阿拉伯语或希伯来语,即使文本仍以土耳其语显示,您的布局也会被镜像。

Specifically "start" means "right" if:

具体来说,“开始”意味着“正确”,如果:

  • the current system language is RTL(Arabic, Hebrew...)
  • AND the android device is API 17 or higher
  • AND android:supportsRtlis set to truein the manifest
  • 当前的系统语言是 RTL(阿拉伯语、希伯来语...)
  • 并且 android 设备是API 17 或更高版本
  • 并且android:supportsRtl在清单中设置为true

Otherwise is means "left".

否则就是“左”的意思。

So you get this warning if you have used android:layout_gravity="start"or any start/end attribute in any of your layout and you have not set android:supportsRtl="true"in the manifest.

因此,如果您在任何布局中使用了android:layout_gravity="start"或任何开始/结束属性,并且未在清单中设置android:supportsRtl="true",则会收到此警告。

Note that, if your min SDK is 16 or below and you do not want to support RTL, you actually have to choose one of the warning:

请注意,如果您的最小 SDK 为 16 或以下,并且您不想支持 RTL,则实际上必须选择以下警告之一:

  • if you do replace start with left you will get the warning :Use "start" instead of "left" to ensure correct behavior in right-to-left localesId=RtlHardCoded
  • if you set android:supportsRtlto false: Attribute "supportsRtl" is only used in API level 17 and higher (current min is 9). Id=UnusedAttribute
  • otherwise: ** The project references RTL attributes, but does not explicitly enable or disable RTL support with android:supportsRtl in the manifest** Id=RtlEnabled
  • 如果您确实用左替换开始,您将收到警告:使用“开始”而不是“左”以确保从右到左的语言环境中的正确行为Id= RtlHardCoded
  • 如果您将android:supportsRtl设置为false属性“supportsRtl”仅用于 API 级别 17 及更高级别(当前最小值为 9)。Id =未使用的属性
  • 否则: ** 项目引用 RTL 属性,但未在清单中使用 android:supportsRtl 显式启用或禁用 RTL 支持** Id= RtlEnabled

If you do not support RTL, it seems logical to set RtlHardCodedto Info instead of warning.

如果您不支持 RTL,则将RtlHardCoded设置为 Info 而不是警告似乎是合乎逻辑的。

More info:

更多信息:

http://android-developers.blogspot.co.il/2013/03/native-rtl-support-in-android-42.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+blogspot/hsDu+(Android+Developers+Blog)

http://android-developers.blogspot.co.il/2013/03/native-rtl-support-in-android-42.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+blogspot/hsDu+(Android+Developers+Blog )

http://developer.android.com/guide/topics/manifest/application-element.html#supportsrtl

http://developer.android.com/guide/topics/manifest/application-element.html#supportsrtl