androidlocalizationandroid-fonts

How get the localized font works at runtime?


I have 3 localized files xml : app_font_xml, app_font_xml (it), app_font_xml(zh)

app_font_xml : (the others are identical but use a different android:font)

<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android">
    <font
        android:fontStyle="normal"
        android:fontWeight="400"
        android:font="@font/en_font" />
    <font
        android:fontStyle="italic"
        android:fontWeight="400"
        android:font="@font/en_font" />
</font-family>

When I change the language in the phone settings, the font is not updated.

I have to kill and restart the application to get the new font.

I would like the new font at runtime.


Solution

  • you should localized the "res/style" and not "res/font" folder