mkafiyan
mkafiyan

Reputation: 954

Android Action Bar Style Generator : Change text color of action bar

I use "Android Action Bar Style Generator" website to generate styles for my actionBar. I want to change the text color of my action bar to white , I tried to do it with <item name="android:textColor">#FFF</item> in manifest but It didn't work. can any one help me ? I also test this way but it didn't answer. I used appcompat in this project. this style generator give me values,drawable folder and some other folder. this is the style generator gives me

<resources>

<style name="Theme.Example" parent="@style/Theme.AppCompat">
    <item name="actionBarItemBackground">@drawable/selectable_background_example</item>
    <item name="popupMenuStyle">@style/PopupMenu.Example</item>
    <item name="dropDownListViewStyle">@style/DropDownListView.Example</item>
    <item name="actionBarTabStyle">@style/ActionBarTabStyle.Example</item>
    <item name="actionDropDownStyle">@style/DropDownNav.Example</item>
    <item name="actionBarStyle">@style/ActionBar.Solid.Example</item>
    <item name="actionModeBackground">@drawable/cab_background_top_example</item>
    <item name="actionModeSplitBackground">@drawable/cab_background_bottom_example</item>
    <item name="actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Example</item>


</style>

<style name="ActionBar.Solid.Example" parent="@style/Widget.AppCompat.ActionBar.Solid">
    <item name="background">@drawable/ab_solid_example</item>
    <item name="backgroundStacked">@drawable/ab_stacked_solid_example</item>
    <item name="backgroundSplit">@drawable/ab_bottom_solid_example</item>
    <item name="progressBarStyle">@style/ProgressBar.Example</item>
</style>

<style name="ActionBar.Transparent.Example" parent="@style/Widget.AppCompat.ActionBar">
    <item name="background">@drawable/ab_transparent_example</item>
    <item name="progressBarStyle">@style/ProgressBar.Example</item>
</style>

<style name="PopupMenu.Example" parent="@style/Widget.AppCompat.PopupMenu"> 
    <item name="android:popupBackground">@drawable/menu_dropdown_panel_example</item>   
</style>

<style name="DropDownListView.Example" parent="@style/Widget.AppCompat.ListView.DropDown">
    <item name="android:listSelector">@drawable/selectable_background_example</item>
</style>
    <style name="ActionButton.CloseMode.Example" parent="@style/Widget.AppCompat.ActionButton.CloseMode">
    <item name="android:background">@drawable/btn_cab_done_example</item>
</style>

I add this two line to this style

 <style name="Example" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionMenuTextColor">#fff</item>
</style>

<style name="Example.ActionBar.Text" parent="@android:style/TextAppearance">
    <item name="android:textColor">#fff</item>
</style>

but still not working.

Upvotes: 2

Views: 601

Answers (1)

tasomaniac
tasomaniac

Reputation: 10342

You should have custom ActionBar style in your theme. I think ActionBar Style Generator also creates a theme already.

What you should do is to add something like below into your theme.

<resources>

    <style name="Theme.Example" parent="@style/Theme.AppCompat">
        ......

        <item name="actionBarStyle">@style/myTheme.ActionBar</item>
        <item name="actionMenuTextColor">@color/actionBarText</item>

    </style>

    <style name="ActionBar.Solid.Example" parent="@style/Widget.AppCompat.ActionBar.Solid">
        <item name="titleTextStyle">@style/myTheme.ActionBar.Text</item>
    </style>

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

</resources>

Upvotes: 2

Related Questions