Android-为什么属性TextAppearanceLarge和TextAppearanceMedium定义了不同的文本颜色

Mar*_*n P 5 android

styles.xml文件中有3种样式:

<style name="TextAppearance.Large">
    <item name="android:textSize">22sp</item>
</style>
<style name="TextAppearance.Medium">
    <item name="android:textSize">18sp</item>
</style>
<style name="TextAppearance.Small">
    <item name="android:textSize">14sp</item>
    <item name="android:textColor">?textColorSecondary</item>
</style>
Run Code Online (Sandbox Code Playgroud)

TextAppearance.Small具有不同的颜色,但TextAppearance.Large和TextAppearance.Medium应该具有相同的颜色。

如果在TextView中设置以下样式:

android:textAppearance="?android:attr/textAppearanceLarge"
Run Code Online (Sandbox Code Playgroud)

android:textAppearance="?android:attr/textAppearanceMedium"
Run Code Online (Sandbox Code Playgroud)

它们的颜色略有不同。

为什么以及在哪里可以找到这些颜色?

Phi*_*795 0

如果您想查看属性或方法的声明,请右键单击属性-> 打开转到子菜单-> 单击声明或使用快捷键Strg + B

现在您可以看到所选主题中的attrs.xml 。

有一个内联注释向您显示样式参考。

就我而言,我使用浅色主题,该主题针对不同的文本大小具有不同的颜色。