4
votes

I'm having some troubles changing the color for the ActionBar. I'm using AppCompat library for support. Everything else works: like background, or selector ... but the title color isn't changing.

This is my style file:

<resources xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">

    <style name="Theme.Customtitletheme" parent="@style/Theme.AppCompat.Light">
        <item name="actionBarItemBackground">@drawable/selectable_background_customtitletheme</item>
        <item name="android:actionBarItemBackground" tools:targetApi="14">@drawable/selectable_background_customtitletheme</item>
        <item name="popupMenuStyle">@style/PopupMenu.Customtitletheme</item>
        <item name="android:popupMenuStyle" tools:targetApi="11">@style/PopupMenu.Customtitletheme</item>
        <item name="dropDownListViewStyle">@style/DropDownListView.Customtitletheme</item>
        <item name="android:dropDownListViewStyle">@style/DropDownListView.Customtitletheme</item>
        <item name="actionBarTabStyle">@style/ActionBarTabStyle.Customtitletheme</item>
        <item name="android:actionBarTabStyle" tools:targetApi="11">@style/ActionBarTabStyle.Customtitletheme</item>
        <item name="actionDropDownStyle">@style/DropDownNav.Customtitletheme</item>
        <item name="android:actionDropDownStyle" tools:targetApi="11">@style/DropDownNav.Customtitletheme</item>
        <item name="actionBarStyle">@style/ActionBar.Solid.Customtitletheme</item>
        <item name="android:actionBarStyle" tools:targetApi="11">@style/ActionBar.Solid.Customtitletheme</item>
        <item name="actionModeBackground">@drawable/cab_background_top_customtitletheme</item>
        <item name="android:actionModeBackground" tools:targetApi="11">@drawable/cab_background_top_customtitletheme</item>
        <item name="actionModeSplitBackground">@drawable/cab_background_bottom_customtitletheme</item>
        <item name="android:actionModeSplitBackground" tools:targetApi="14">@drawable/cab_background_bottom_customtitletheme</item>
        <item name="actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Customtitletheme</item>
        <item name="android:actionModeCloseButtonStyle" tools:targetApi="11">@style/ActionButton.CloseMode.Customtitletheme</item>
        <item name="actionMenuTextColor">@color/actionbar_text</item>
        <item name="android:actionMenuTextColor" tools:targetApi="11">@color/actionbar_text</item>
    </style>

    <style name="ActionBar.Solid.Customtitletheme" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
        <item name="background">@drawable/ab_solid_customtitletheme</item>
        <item name="android:background">@drawable/ab_background_textured_customtitletheme</item>
        <item name="backgroundStacked">@drawable/ab_stacked_solid_customtitletheme</item>
        <item name="android:backgroundStacked" tools:targetApi="14">@drawable/ab_stacked_solid_customtitletheme</item>
        <item name="backgroundSplit">@drawable/ab_bottom_solid_customtitletheme</item>
        <item name="android:backgroundSplit" tools:targetApi="14">@drawable/ab_background_textured_customtitletheme</item>
        <item name="progressBarStyle">@style/ProgressBar.Customtitletheme</item>
        <item name="android:progressBarStyle">@style/ProgressBar.Customtitletheme</item>
        <item name="titleTextStyle">@style/ActionBar.CustomTitle</item>
        <item name="android:textStyle">@style/ActionBar.CustomTitle</item>
    </style>

    <style name="PopupMenu.Customtitletheme" parent="@style/Widget.AppCompat.Light.PopupMenu">
        <item name="android:popupBackground">@drawable/menu_dropdown_panel_customtitletheme</item>
    </style>

    <style name="DropDownListView.Customtitletheme" parent="@style/Widget.AppCompat.Light.ListView.DropDown">
        <item name="android:listSelector">@drawable/selectable_background_customtitletheme</item>
    </style>

    <style name="ActionBarTabStyle.Customtitletheme" parent="@style/Widget.AppCompat.Light.ActionBar.TabView">
        <item name="android:background">@drawable/tab_indicator_ab_customtitletheme</item>
    </style>

    <style name="DropDownNav.Customtitletheme" parent="@style/Widget.AppCompat.Light.Spinner.DropDown.ActionBar">
        <item name="android:background">@drawable/spinner_background_ab_customtitletheme</item>
        <item name="android:popupBackground">@drawable/menu_dropdown_panel_customtitletheme</item>
        <item name="android:dropDownSelector">@drawable/selectable_background_customtitletheme</item>
    </style>

    <style name="ProgressBar.Customtitletheme" parent="@style/Widget.AppCompat.ProgressBar.Horizontal">
        <item name="android:progressDrawable">@drawable/progress_horizontal_customtitletheme</item>
    </style>

    <style name="ActionButton.CloseMode.Customtitletheme" parent="@style/Widget.AppCompat.Light.ActionButton.CloseMode">
        <item name="android:background">@drawable/btn_cab_done_customtitletheme</item>
    </style>

    <!-- ActionBar title text -->
    <style name="ActionBar.CustomTitle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
        <item name="android:textColor">@color/actionbar_text</item>
        <!-- The textColor property is backward compatible with the Support Library -->
    </style>

    <!-- this style is only referenced in a Light.DarkActionBar based theme -->
    <style name="Theme.Customtitletheme.Widget" parent="@style/Theme.AppCompat">
        <item name="popupMenuStyle">@style/PopupMenu.Customtitletheme</item>
        <item name="android:popupMenuStyle" tools:targetApi="11">@style/PopupMenu.Customtitletheme</item>
        <item name="dropDownListViewStyle">@style/DropDownListView.Customtitletheme</item>
        <item name="android:dropDownListViewStyle">@style/DropDownListView.Customtitletheme</item>
    </style>

</resources>

I have also used different values folders, like values-v14 or values-v11, but the same result.

If I change the parent from "Theme.AppCompat.Light" to "Theme.AppCompat.Dark" the color changes, but when I want to use some custom color it is not working...

Also, this is how I used the specified theme in manifest:

<activity
    android:name="com.cos.ShareActivity"
    android:label="Share File"
    android:parentActivityName="com.cos.FileManagerActivity"
    android:theme="@style/Theme.Customtitletheme" >

    <!-- Parent activity meta-data to support 4.0 and lower -->
    <meta-data
        android:name="android.support.PARENT_ACTIVITY"
        android:value="com.cos.FileManagerActivity" />
</activity>

What I am doing wrong that the color item is ignored ?

1
After so much time lost trying to figure it out, I found that it was a typo ... damn ... I have used android:textStyle instead of android:titleTextStyle. When I typed in that line the IDE auto-suggest typed the first one :( ....Ionut Negru
Hi Ionut, you should put your comment as your own answer and accept it. It might be better to someone which has the same issue than yours - Thank you.fllo
Thank you for the suggestion @Fllo, I will do that.Ionut Negru

1 Answers

2
votes

After so much time lost trying to figure it out, I found that it was a typo ... damn ... I have used android:textStyle instead of android:titleTextStyle. When I typed in that line the IDE auto-suggest typed the first one :(