gpt4 book ai didi

android - fontFamily 属性不能通过 textAppearance 工作

转载 作者:行者123 更新时间:2023-11-29 22:59:18 27 4
gpt4 key购买 nike

我有下一个风格:

 <style name="Text.Light">
<item name="android:fontFamily">@font/open_sans_light</item>
</style>

如果我在设计时通过 textAppearance 将它设置为 TextView 就像 android:textAppearance="@style/Text.Italic"它显示斜体字体,但在运行时它不影响。但是,如果像 android:fontFamily="@font/open_sans_italic" 一样直接在 TextView 中使用 fontFamily,它在两种情况下(设计和运行时)都能完美运行。我究竟做错了什么?有我的字体系列 xml:

<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="UnusedAttribute">

<font
android:font="@font/open_sans_regular"
android:fontStyle="normal"
android:fontWeight="400"
app:font="@font/open_sans_regular"
app:fontStyle="normal"
app:fontWeight="400" />

<font
android:font="@font/open_sans_italic"
android:fontStyle="italic"
android:fontWeight="400"
app:font="@font/open_sans_italic"
app:fontStyle="italic"
app:fontWeight="400" />
</font-family>

最佳答案

问题是我在 AppTheme 中选择了 textViewStyle 并且有 fontFamily。根据post textAppearance 具有最低优先级,它不能覆盖在主题或其他任何地方定义的其他样式。

关于android - fontFamily 属性不能通过 textAppearance 工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57100207/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com