Android---全局设置字体

2018-04-19  本文已影响0人  HPD_黄霹雳

参考文章:https://www.zhihu.com/question/38615247

步骤1:在res下建立font文件夹,把字体资源 tzlth.TTF 导入

步骤2:在font下建立font_style.xml

<font-family xmlns:app="http://schemas.android.com/apk/res-auto">
    <font
        app:font="@font/fzlth"
        app:fontStyle="normal" />
</font-family>

步骤3:在values/styles.xml中添加 <item name="android:fontFamily">@font/font_style</item>

<resources>

    <!-- Base application theme. -->
    <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/font_style</item>
    </style>

</resources>

然后看textview效果是否生效

上一篇 下一篇

猜你喜欢

热点阅读