Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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

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

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

Thanks

like image 320
manowar_manowar Avatar asked Dec 09 '14 12:12

manowar_manowar


People also ask

How do I enable RTL support on android?

First of all, you must add android:supportsRtl="true" to the <application> element in your manifest file for your app to supporting RTL design. Trick: If your app supports multiple languages and if you have code snippet like config. setLayoutDirection(Locale.US) you must change it.

What is supportsRtl?

android:supportsRtl. Declares whether your application is willing to support right-to-left (RTL) layouts. If set to true and targetSdkVersion is set to 17 or higher, various RTL APIs will be activated and used by the system so your app can display RTL layouts.


1 Answers

If you do not support RTL (= Right To Left locales), you need to replace all references of start by left and end by right in your xml layouts.

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.

Specifically "start" means "right" if:

  • the current system language is RTL (Arabic, Hebrew...)
  • AND the android device is API 17 or higher
  • AND android:supportsRtl is set to true in the manifest

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.

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:

  • 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 locales Id=RtlHardCoded
  • if you set android:supportsRtl to 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

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

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://developer.android.com/guide/topics/manifest/application-element.html#supportsrtl

like image 71
BenL Avatar answered Nov 04 '22 20:11

BenL