Changing Locale does not changing Font style
Asked Answered
P

1

6

I use this approach to set the locale when the user chooses a new language.

Also I use fonts in styles like this:

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">


    <item name="android:textAppearance">@style/Font.Default</item>

    </style>

And a style for "EN" in values folder:

<style name="Font.Default" parent="@android:style/TextAppearance.Small">
    <item name="android:fontFamily">@font/futuralt</item>
    <item name="fontFamily">@font/futuralt</item>
</style>

And another style for another language "ar"(representing Arabic) with another font in values-ar folder:

<style name="Font.Default" parent="@android:style/TextAppearance.Small">
    <item name="android:fontFamily">@font/gesstwolight</item>
    <item name="fontFamily">@font/gesstwolight</item>
</style>

The problem is when the locale changes, the font representing the locale doesn't being applied Unless app restarts. How to Change the font without restarting the app after setting locale?

Papillote answered 9/12, 2018 at 12:48 Comment(0)
D
0

You could call recreate in some place after changing locale.

 yourActivity.this.recreate();
Deidradeidre answered 9/12, 2018 at 13:2 Comment(1)
I Already tried this.The problem is that Recreating activity does not change the font!Papillote

© 2022 - 2024 — McMap. All rights reserved.