0

I want to make my Toolbar always arrange it's children Right-To-Left rtl like that enter image description here

3
  • Are you looking to support it if the user supports Arabic, Urdu, Hebrew languages?
    – Eugene H
    Commented Apr 30, 2016 at 22:03
  • My App will be only in Arabic Commented Apr 30, 2016 at 22:07
  • I have tried ViewCompat.setLayoutDirection(view, direction) but nothing happened Commented Apr 30, 2016 at 22:18

2 Answers 2

1

Add this to your manifest.

<application
    ...
    android:supportsRtl="true">

</application>
1
  • Thank you, but this code will change children arrange direction due locale change, that's not what I need, I need to make toolbar always like in image whatever the device locale is. Commented Apr 30, 2016 at 23:00
0

I found solution for that problem.

First and thanks to @Eugene

<application
...
android:supportsRtl="true">
</application>

Second Force every Activity to use specific Locale

private void updateResources(String language) {
    Locale locale = new Locale(language);
    Locale.setDefault(locale);

    Resources resources = getResources();

    Configuration configuration = resources.getConfiguration();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        configuration.setLocale(locale);
    } else {
        //noinspection deprecation
        configuration.locale = locale;
    }

    resources.updateConfiguration(configuration, resources.getDisplayMetrics());
}

Not the answer you're looking for? Browse other questions tagged or ask your own question.