Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linearlayout order is reversed on some devices

I have a LinearLayout and on some devices all the views are reversed.

The Good Version:

[b1] [b2] [b3]

On some devices:

[b3] [b2] [b1]

Why does that happen and how can I fix it?

like image 912
user88382 Avatar asked Mar 19 '23 01:03

user88382


1 Answers

If you're targeting and testing on API level >=17 (i.e. Android 4.2) this might be caused by RTL support, as described here.

If you don't want this, you can either change android:layoutDirection for each particular view (and since the default is inherit, the root view should suffice) or you can disable it for the whole application by setting android:supportsRtl="false" in the AndroidManifest.xml file.

Or, you could also target an API level < 17, since it will then be disabled for compatibility (but this would lock you out of certain APIs).

like image 62
matiash Avatar answered Mar 28 '23 04:03

matiash