我正在使用 v7 appcompat 21 库在 Lollipop 之前的设备上使用新的 Material 样式。我的styles.xml 看起来像这样:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:textColorPrimary">#ff0000</item>
<item name="android:textColorPrimaryInverse">#ff0000</item>
</style>
我正在尝试更改操作栏上的文本颜色。但无论我为 textColorPrimary 或 textColorPrimaryInverse 放置什么,颜色始终是白色的。如果我从 Theme.AppCompat 继承,我可以重写“textColorPrimary”,如果我从 Theme.AppCompat.Light 继承,我可以重写“textColorPrimaryInverse”。但是在使用 Light.DarkActionBar 主题时两者都不起作用。
我肯定会使用 AppTheme,因为设置诸如 colorPrimary 之类的属性来更改操作栏背景颜色可以正常工作。我没有使用任何其他资源限定符样式文件。
我已经翻阅了 android 样式文件,但似乎无法确定要覆盖的属性。有任何想法吗?这是一个 appcompat 错误吗?
最佳答案
你可以通过主题的actionBarStyle
属性来改变它。
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar.Solid">
<item name="titleTextStyle">@style/MyTitleTextStyle</item>
</style>
<style name="MyTitleTextStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">CHANGE_COLOR_HERE</item>
</style>
关于android - 在 AppCompat 21 中使用 Light.DarkActionBar 主题更改 ActionBar 标题文本颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26870698/