使用Light.DarkActionBar主题AppCompat 21动作条更改标题文本颜色 [英] Change ActionBar title text color using Light.DarkActionBar theme in AppCompat 21

查看:2995
本文介绍了使用Light.DarkActionBar主题AppCompat 21动作条更改标题文本颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是V7 appcompat 21库使用的pre-棒棒糖设备,新材料的风格。我styles.xml看起来是这样的:

I'm using the v7 appcompat 21 library to use the new Material styles on pre-Lollipop devices. My styles.xml looks like this:

<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主题的时候。

I am trying to change the text color on the action bar. But no matter what I put for textColorPrimary or textColorPrimaryInverse, the color is always white. If I inherit from Theme.AppCompat, I can override "textColorPrimary", and if I inherit from Theme.AppCompat.Light, I can override "textColorPrimaryInverse". But neither work when using the Light.DarkActionBar theme.

我肯定用AppTheme因为像colorPrimary设置属性来改变动作条的背景颜色正常工作。我没有使用任何其他资源预选赛样式文件。

I am definitely using the AppTheme because setting attributes like colorPrimary to change the actionbar background color works fine. I am not using any other resource qualifier style files.

我已经通过Android风格文件挖似乎无法找出什么属性来覆盖。有任何想法吗?这是一个appcompat错误?

I've dug through the android styles files and can't seem to figure out what attribute to override. Any ideas? Is this an appcompat bug?

推荐答案

您可以用主题 actionBarStyle 属性进行更改。

You can change it with actionBarStyle attribute of theme.

<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>

这篇关于使用Light.DarkActionBar主题AppCompat 21动作条更改标题文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆