Question

I am using the ActionBarSherlock and almost everything seems to work fine. But I want the title text color in white. When using the Sherlock-Actionbar it works fine but not with the original ActionBar in Android 4

In an act of desperation I tried this:

 <style name="Widget.AppTheme.ActionBar" parent="Widget.Sherlock.Light.ActionBar">
        <item name="titleTextStyle">@style/TextAppearance.AppTheme.Widget.ActionBar.Title</item>
        <item name="android:gravity">center</item>

        <item name="android:background">@color/white</item>
        <item name="android:textColor">@color/white</item>
</style>

and found that the background changed as told to white. So this is obviously the right place to change. But still changing the textColor to white doesn't work for me.

I'm using this as my Theme:

<style name="AppTheme" parent="Theme.Sherlock.Light">
        <item name="android:actionBarStyle">@style/Widget.AppTheme.ActionBar</item>
        <item name="actionBarStyle">@style/Widget.AppTheme.ActionBar</item>

        <item name="textColorPrimary">@color/white</item>
        <item name="android:textColor">@color/white</item>
        ...
</style>

So any idea what could be the problem? Why is it working with the background but not with the textColor?

Thanks, Tobias

--- EDIT FROM HERE ---

I just found out that if I use my theme programmaticall like

setTheme(R.style.Widget_AppTheme_ActionBar);

It works. But if I rely on the settings I have in my Manifest it doesn't.

<application ... android:theme="@style/AppTheme" >

but

<application ... android:theme="@style/Widget_AppTheme_ActionBar" >

would do fine - even though the other styles from the AppTheme wouldn't be set. So it looks like using a theme that defines an own ActionBarStyle doesn't work.

Has anyone any idea?

Was it helpful?

Solution

Okay, sorry for answering my own question. I eventually realized my problem. Of cause I have to use these two arguments

<item name="titleTextStyle">@style/TextAppearance.AppTheme.Widget.ActionBar.Title</item>
<item name="android:titleTextStyle">@style/TextAppearance.AppTheme.Widget.ActionBar.Title</item>

Since the first one is working for Android 2.x with the ActionBarSherlock and the second one is doing the same for the native Action Bar.

I hope this helps someone who has the same trouble as I had.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top