更改Android应用程序的所有字体 [英] Changing all typefaces of an android application

查看:106
本文介绍了更改Android应用程序的所有字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更改我的android应用程序的整个字体?
之前,我在github上看到了这篇文章。该解决方案仅对设备有效低于api21。
对于android 5,即使我们添加具有样式的 values-v21 文件夹,该方法也无法使用。 xml

How can I change the entire typeface of my android application? previously I saw this post on github.The solution work fine only for devices with lower than api 21. For android 5 this method doesn't work even if we add a values-v21 folder with styles.xml separately.

这是我的 values-v21 / styles.xml

<resources>

    <style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">

    </style>

    <style name="AppTheme" parent="AppBaseTheme">
        <item name="android:typeface">serif</item>
    </style>

</resources>


推荐答案

<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:textViewStyle">@style/RobotoTextViewStyle</item>
    <item name="android:buttonStyle">@style/RobotoButtonStyle</item>
</style>

<style name="RobotoTextViewStyle" parent="android:Widget.TextView">
    <item name="android:fontFamily">sans-serif-light</item>
</style>

<style name="RobotoButtonStyle" parent="android:Widget.Holo.Button">
    <item name="android:fontFamily">sans-serif-light</item>
</style>

然后将主题应用于您的应用

Then Apply theme to your app

<application
    android:theme="@style/AppTheme" >
</application>

这篇关于更改Android应用程序的所有字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆