系统语言更改时,不应用字体

时间:2020-05-15 05:45:27

标签: java android fonts

我希望我的应用程序支持不同的语言,现在我只添加了两种(英语和俄语),因为遇到了这个问题。我还为整个应用添加了一种样式的字体:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
       ...
       ...
    <item name="android:fontFamily">@font/finger_paint</item> // this line
</style>

由于我的电话语言通常是英语,因此在使用英语的情况下,我的应用程序运行良好,因此可以使用该字体: enter image description here

但是当我将电话语言更改为俄语时,会发生一些奇怪的事情: enter image description here

该字体适用于数字,但不适用于俄语单词! 我试图制作另一个可绘制的资源文件(styles-ru.xml)并在其中添加字体,但是没有任何变化:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    ...
    <item name="android:fontFamily">@font/carter_one</item> // this line
</style>

我的值文件夹如下所示: enter image description here

为什么会这样?我怎么解决这个问题?谢谢你的帮助。

2 个答案:

答案 0 :(得分:1)

使用此库以编程方式向您的应用添加字体

https://github.com/chrisjenx/Calligraphy

答案 1 :(得分:0)

问题不是因为我。原来,这种字体根本不支持俄语字母,例如,当我在项目中添加德语时,该字体就可以完美工作了。

相关问题