简体   繁体   中英

Why can't I change my actionbar text color?

I used this generator to create a custom theme for my app: http://jgilfelt.github.io/android-actionbarstylegenerator/

But there is one thing that i want to change, that this generator does not support: The textcolor of the actionbar.

I tried doing this manually with this code:

<resources>

<style name="Theme.Bessel" parent="@android:style/Theme.Holo.Light">
    <item name="android:titleTextStyle">@style/MyTextAppearance</item>
</style>

<style name="MyTextAppearance" parent="android:TextAppearance.Holo.Widget.ActionBar.Title">
    <item name="android:textColor">#F8F8FF</item>
</style>

</resources>

But the textcolor of my actionbar remains unchanged. Any tips?

Update:

<resources>

<style name="Theme.Bessel" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/Your.ActionBar</item>


</style>
<style name="Your.ActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
    <item name="android:background">@drawable/ab_background_textured_bessel</item>
    <item name="android:backgroundStacked">@drawable/ab_stacked_solid_bessel</item>
    <item name="android:backgroundSplit">@drawable/ab_background_textured_bessel</item>
    <item name="android:progressBarStyle">@style/ProgressBar.Bessel</item>
    <item name="android:titleTextStyle">@style/MyTextAppearance</item>
</style>

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

You need to be applying android:titleTextStyle to a style that is inherent of Widget.ActionBar . So, it looks like in your case that would be Widget.Holo.Light.ActionBar .

<style name="Your.ActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
    <item name="android:titleTextStyle">@style/MyTextAppearance</item>
</style>

Then apply your ActionBar style in your root theme using android:actionBarStyle .

<style name="Theme.Bessel" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/Your.ActionBar</item>
</style>

To change the tab text color, you need a theme that inherits Widget.ActionBar.TabText , in your case that looks like it'll be Widget.Holo.Light.ActionBar.TabText . Then to apply the style use android:actionBarTabTextStyle in your root theme.

<style name="Theme.Bessel" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionBarTabTextStyle">@style/Your.Widget.ActionBar.TabText</item>
</style>

<style name="Your.Widget.ActionBar.TabText" parent="@android:style/Widget.Holo.Light.ActionBar.TabText">
    <item name="android:textColor">#F8F8FF</item>
</style>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM