2

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.

Community
  • 1
  • 1
mkafiyan
  • 944
  • 2
  • 9
  • 31
  • If you used the generator, then add your new styles in the styles.xml it generated for you. Do not add them to the AndroidManifest.xml – Jared Burrows Oct 27 '14 at 20:39
  • @JaredBurrows I add it to style.xml also, but it has error. look at pls (https://developer.appcelerator.com/question/176490/how-to-change-the-color-of-action-bar-title-and-tab-title-by-using-android-action-bar-style-generator-) I did exactly like this. – mkafiyan Oct 27 '14 at 20:48
  • Post your XML and view the answer down below. – Jared Burrows Oct 27 '14 at 20:49
  • @JaredBurrows I post my code mind me ask u to look at them? – mkafiyan Oct 27 '14 at 21:02
  • Look at tasomaniac's answer, you are not referencing "Example.ActionBar.Text" as your android:actionBarStyle – Jared Burrows Oct 27 '14 at 21:04

1 Answers1

2

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>
tasomaniac
  • 10,234
  • 6
  • 52
  • 84