【问题标题】:Not able to override fonts in different views when I set a font in the app theme在应用程序主题中设置字体时无法覆盖不同视图中的字体
【发布时间】:2020-08-17 12:21:09
【问题描述】:

我在我的应用主题中设置了一种字体,例如 font1:

<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
    ...
    <item name="fontFamily">@font/font1</item>
    ...
</style>

然后,当我尝试将另一种字体设置为我的 TextViews 之一时,例如 font2:

<TextView
...
android:fontFamily="@font/font2"/>

我的期望是我会在此 TextView 的屏幕上看到 font2 样式,但它没有生效并仍然显示 font1 样式。

所以我的问题是,为什么 font2 不应用于 TextView 并且仍然显示 font1

注意:我使用的是 MaterialComponenets 主题,而不是 AppCompat 主题

【问题讨论】:

    标签: android fonts material-components-android


    【解决方案1】:

    试试

    app:fontFamily="@font/font2" 
    

    【讨论】:

      猜你喜欢
      • 2020-07-27
      • 2017-02-24
      • 2018-10-07
      • 1970-01-01
      • 1970-01-01
      • 2012-06-03
      • 2017-08-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多