我无法在动作栏中更改字幕的颜色

时间:2014-04-08 23:06:58

标签: android android-actionbar

我正在尝试更改操作栏中字幕的颜色,但它不会改变。

这是截图。 enter image description here

这是styles.xml

<style name="AppBaseTheme" parent="Theme.AppCompat.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:actionBarStyle">@style/MyActionBar</item>
    <item name="android:subtitleTextStyle">@style/MyActionBar.TitleTextStyle</item>
</style>

<!-- ActionBar styles -->
<style name="MyActionBar" parent="android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
    <item name="android:background">@color/actionbarBackground</item>
    <item name="android:tabStripEnabled">true</item>
    <item name="backgroundSplit">@color/white</item>
</style>

<style name="MyActionBar.TitleTextStyle" parent="android:style/TextAppearance.Holo.Widget.ActionBar.Subtitle">
    <item name="android:textColor">@color/white</item>
</style>

2 个答案:

答案 0 :(得分:7)

android:subtitleTextStyle属性是Widget.ActionBar的继承。您需要将其移至MyActionBar样式,而不是根主题。

此外,不要忘记添加支持库兼容性,因为您正在使用AppCompat:

<style name="MyActionBar" parent="android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
    ...
    <item name="android:subtitleTextStyle">@style/MyActionBar.TitleTextStyle</item>
    <!-- Support library compatibility -->
    <item name="subtitleTextStyle">@style/MyActionBar.TitleTextStyle</item>
</style>

答案 1 :(得分:0)

在活动文件中添加以下代码

 actionBar.setSubtitle(Html.fromHtml("<font color='subtitleColor'>Here ActionBar Subtitle</font>"));