不同语言的字体资源

Font resources for different Languages

我正在尝试使用字体资源目录并在 xml 文件中使用不同的字体,以便优先使用它们。我读了这个 但我无法解决问题。我正在使用支持库 v27,我知道它支持 res 中的字体而不是资产文件夹。每当我更改应用程序的语言时,它只使用位于 font-fa-rIR 文件夹中的字体。我希望应用程序分别为不同类型的语言使用不同的字体。我附上了应用程序 res 目录中的图像。我的问题在哪里?我该如何解决?提前致谢。

preference_button.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:padding="8dp">

    <TextView
        android:id="@android:id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:fontFamily="@font/font_1" />

    <TextView
        android:id="@+id/summary"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:fontFamily="@font/font_1" />

</LinearLayout>

可能这个阙对你有帮助

参考:Chnaging Locale It self

Locale locale2 = new Locale("fr"); 
Locale.setDefault(locale2);
Configuration config2 = new Configuration();
config2.locale = locale2;
getBaseContext().getResources().updateConfiguration(
    config2, getBaseContext().getResources().getDisplayMetrics());

来自 Res 的字体

TextView tv_the = (TextView) findViewById(R.id.the);
Typeface face = Typeface.createFromAsset(getAssets(), "font.ttf");
tv_the.setTypeface(face);

更多信息: