Ahmed Mostafa
Ahmed Mostafa

Reputation: 918

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

Upvotes: 0

Views: 627

Answers (2)

Ahmed Mostafa
Ahmed Mostafa

Reputation: 918

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

Upvotes: 0

Eugene H
Eugene H

Reputation: 3568

Add this to your manifest.

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

</application>

Upvotes: 1

Related Questions