Home » Android » android – Automatic layout mirroring in right-to-left locale with lollipop

android – Automatic layout mirroring in right-to-left locale with lollipop

Posted by: admin June 15, 2020 Leave a comment

Questions:

I have recently checked a widget of an application I developed on a device running lollipop and a right-to-left locale (Hebrew). The problem is that Android 5 (lollipop) automatically mirrors everything on the widget (even images), so a text or image that is left adjusted will become right adjusted. This breaks up the widget design. Is there a way to tell Android not to do this for the widget? Is there a layout setting that will prevent this from happening?

How to&Answers:

Just found the answer. Add to the main/outer layout of the widget the following,

android:layoutDirection="ltr"

and it will force the layout to be left-to-right, even in right-to-left languages. It looks like Lollipop has changed the default setting of the above attribute according to the text direction of the currently active locale.

Answer:

Just goto android manifest.xml file and change

android:supportsRtl="true" to 
 android:supportsRtl="false"