[英]ActionBar title color does not change
I want to change the title color of actionbar to white. 我想将操作栏的标题颜色更改为白色。 I have declared on styles: 我已经声明了样式:
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:windowActionBar">true</item>
<item name="android:actionBarStyle">@style/ProjActionBar</item>
<item name="android:actionBarTabTextStyle">@style/ProjActionBar.TitleTextStyle</item>
</style>
<!-- ActionBar Style -->
<style name="ProjActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">@color/b</item>
<item name="android:backgroundStacked">@color/k1</item>
<!-- This is when tabs are splitted into a second line -->
</style>
<style name="ProjActionBar.TitleTextStyle" parent="@android:style/TextAppearance">
<item name="android:textColor">@color/w</item>
<item name="android:textSize">13sp</item>
</style>
As you can see I have a "actionBarTabTextStyle" declared with the attribute "textColor" to @color/w declared in my colors.xml as: 如您所见,我在我的colors.xml中声明了一个带有@ text / w的属性“ textColor”的“ actionBarTabTextStyle”声明为:
<color name="w">#FFFFFFFF</color>
What happend? 发生了什么事? why the actionbar title does not change textColor? 为什么操作栏标题不会更改textColor?
My project is targeted to min SDK 11 sdkVersion 17 (Honeycomb 3.0+) 我的项目针对的是min SDK 11 sdkVersion 17(Honeycomb 3.0+)
The problem is that you have not actually changed the title text style. 问题是您实际上没有更改标题文本样式。 You have changed the style of the tab text. 您已更改标签文本的样式。 To change the title text style, you want to set android:titleTextStyle
and optionally android:subtitleTextStyle
on your ProjActionBar
style. 要更改标题文字样式,您需要在ProjActionBar
样式上设置android:titleTextStyle
和可选的android:subtitleTextStyle
。
So, your ProjActionBar
becomes this: 因此,您的ProjActionBar
变为:
<style name="ProjActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">@color/b</item>
<item name="android:backgroundStacked">@color/k1</item>
<item name="android:titleTextStyle">@style/ProjActionBar.TitleTextStyle</item>
</style>
Please note that this assumes you are using the native ActionBar components (as indicated by the fact that you are inheriting from @android:style/Widget.Holo.Light.ActionBar
). 请注意,这假设您正在使用本机ActionBar组件(从@android:style/Widget.Holo.Light.ActionBar
继承的事实表明)。 If you want backwards compatibility, you will have to inherit your style from Widget.AppCompat.Light.ActionBar
and use textStyle
instead of android:textStyle
. 如果要向后兼容,则必须从Widget.AppCompat.Light.ActionBar
继承样式,并使用textStyle
而不是android:textStyle
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.