Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 645
a.p. Avatar asked Nov 30 '14 07:11

a.p.


1 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.

like image 82
a.p. Avatar answered Oct 08 '22 23:10

a.p.