ahmed ghanayem ahmed ghanayem - 4 months ago 40
Android Question

force toolbar to arrange children rtl android?

I want to make my

Toolbar
always arrange it's children Right-To-Left
rtl
like that enter image description here

Answer

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());
}
Comments