部分覆盖资源

时间:2018-05-27 13:18:13

标签: android android-styles

我正在寻找一种仅部分覆盖样式的方法:

在values \ styles.xml

<style name="TitleBarTextAppearance" parent="android:TextAppearance">
    <item name="android:textColor">@color/colorAccent</item>
</style>

在v16 \ styles.xml

<style name="TitleBarTextAppearance" parent="android:TextAppearance">
    <item name="android:fontFamily">@font/bilbo_swash_caps</item>
</style>

但是我想在两种情况下从更一般的规则中获取textColor。有没有办法做到这一点?

1 个答案:

答案 0 :(得分:1)

您可以按照以下方式执行此操作:

values\styles.xml

<style name="BaseTitleBarTextAppearance" parent="android:TextAppearance">
    <item name="android:textColor">@color/colorAccent</item>
</style>

<style name="TitleBarTextAppearance" parent="BaseTitleBarTextAppearance"/>

v16\styles.xml

<style name="TitleBarTextAppearance" parent="BaseTitleBarTextAppearance">
    <item name="android:fontFamily">@font/bilbo_swash_caps</item>
</style>