我想创建两个主题,GrayTheme和RedTheme,它们修改一个样式属性。例如,这是我的两个主题,默认字体颜色为白色,对于这两个主题都很好:
<style name="RedTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:textColor">@color/white</item>
</style>
<style name="GrayTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:textColor">@color/white</item>
</style>
但我有一种用于标题TextView的样式。 如果我正在使用RedTheme,我希望HeaderFont样式具有红色textColor,如果是GrayTheme,则希望HeaderFont textColor为灰色,而无需我修改访问此HeaderFont样式的单个xml文件。
<style name="HeaderFont" parent="@android:style/TextAppearance.Medium">
<item name="android:textColor">@color/gray</item>
</style>
我一直在寻找一个优雅的解决方案,但是没有找到任何东西。有什么想法吗?