为 Android 应用设置默认字体系列

Set default font family for Android app

我是 Android studio 的新手,我想知道在阅读接受的答案 here.

我尝试将代码放入 activity_main.xmlAndroidManifest.xml 但它不起作用。

如有任何帮助,我们将不胜感激!

谢谢 KDeogharkar!

看来我必须在 values 文件夹中的 styles.xml 中添加代码。它奏效了:)

/res/values*/themes.xml

在这里选择要扩展的任何父主题

<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:textViewStyle">@style/RobotoFont</item>
</style>
<style name="RobotoFont" parent="android:Widget.TextView">
    <item name="android:fontFamily">sans-serif</item>
</style>
</resources>

然后在您的应用程序清单中

android:theme="@style/AppTheme`"