8

我有这样的xml:

<resources>

<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
</style>

<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
    <item name="android:titleTextStyle">@style/TitleColor</item>
</style>

<style name="MyActionBar" parent="android:Widget.Holo.Light.ActionBar.Solid.Inverse">
    <item name="android:background">#800000</item>
</style>

<style name="TitleColor" parent="android:TextAppearance.Holo.Widget.ActionBar.Title">
    <item name="android:textColor">#000099</item>
</style>
</resources>

背景颜色设置正确,但标题颜色不变。我在哪里犯错了?谢谢!

4

4 回答 4

21

将其更改为:

<resources>

    <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
    </style>

    <style name="AppTheme" parent="AppBaseTheme">
        <item name="android:actionBarStyle">@style/MyActionBar</item>
    </style>

    <style name="MyActionBar" parent="android:Widget.Holo.Light.ActionBar.Solid.Inverse">
        <item name="android:background">#800000</item>
        <item name="android:titleTextStyle">@style/TitleColor</item>
    </style>

    <style name="TitleColor" parent="android:TextAppearance.Holo.Widget.ActionBar.Title">
        <item name="android:textColor">#000099</item>
    </style>
</resources>
于 2013-09-24T19:48:42.353 回答
2

您也可以像这样以编程方式更改

ActionBar actionbar = getSupportedActiobar();
actionBar.setTitle(Html.fromHtml("<font color='#ff0000'>ActionBarTitle </font>"));
于 2014-06-21T08:16:33.470 回答
1

我正在使用这个

<resources>

<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light">
    <item name="actionBarStyle">@style/myTheme.ActionBar</item>
    <item name="actionMenuTextColor">@color/action_text_color</item>
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme"></style>

<style name="myTheme.ActionBar" parent="@style/Widget.AppCompat.ActionBar">
    <item name="titleTextStyle">@style/myTheme.ActionBar.Text</item>
    <item name="background">@drawable/abc_tab_indicator_ab_holo</item>
    <item name="backgroundStacked">@drawable/abc_ab_transparent_dark_holo</item>
    <item name="backgroundSplit">@drawable/abc_ab_bottom_transparent_light_holo</item>
</style>

<style name="myTheme.ActionBar.Text" parent="@android:style/TextAppearance">
    <item name="android:textColor">@color/action_text_color</item>
</style>

于 2013-09-24T19:49:42.053 回答
0

这对我有用...

<style name="MyActionBar"
    parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
    <item name="android:background">@color/titleBarBgColor</item>
    <item name="android:titleTextStyle">@style/EldTheme.ActionBar.TitleTextStyle</item>
    <item name="android:subtitleTextStyle">@style/EldTheme.ActionBar.TitleTextStyle</item>
    <!-- Support library compatibility -->
    <item name="background">@color/titleBarBgColor</item>
    <item name="titleTextStyle">@style/EldTheme.ActionBar.TitleTextStyle</item>
    <item name="subtitleTextStyle">@style/EldTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="EldTheme.ActionBar.TitleTextStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
    <item name="android:textColor">@color/titleBarTextColor</item>
</style>
于 2015-01-15T10:12:04.557 回答