android determine if device is in right to left language/layout

You could create a values-ldrtl folder with a xml file called isrighttoleft.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <bool name="is_right_to_left">true</bool>
</resources>

and in your values folder the same file with:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <bool name="is_right_to_left">false</bool>
</resources>

And finally in Code:

boolean isRightToLeft = getResources().getBoolean(R.bool.is_right_to_left);

The values-ldrtl will only be used on a device where the specific settings (e. g. Language) are right-to-left-read languages.

Leave a Comment