Search code examples
androidandroid-layoutactionbarsherlockandroid-actionbar

Change app's title color from an actionbar created on actionbarstylegenerator


I'm trying to change my actionbar (sherlock) app title color from black to white using android:textColor inside my style but it doesnt seem to work.

I generated this actionbar on http://jgilfelt.github.io/android-actionbarstylegenerator but I thought that the textColor code should work anyway.

Here's the code that I got from the website. What do I have to do to make it white just for the title?

<!-- ActionBar from Generator -->
<style name="Theme.xotab" parent="@style/Theme.xot">
    <item name="actionBarItemBackground">@drawable/selectable_background_xotab</item>
    <item name="popupMenuStyle">@style/PopupMenu.xotab</item>
    <item name="dropDownListViewStyle">@style/DropDownListView.xotab</item>
    <item name="actionBarTabStyle">@style/ActionBarTabStyle.xotab</item>
    <item name="actionDropDownStyle">@style/DropDownNav.xotab</item>
    <item name="actionBarStyle">@style/ActionBar.Solid.xotab</item>
    <item name="actionModeBackground">@drawable/cab_background_top_xotab</item>
    <item name="actionModeSplitBackground">@drawable/cab_background_bottom_xotab</item>
    <item name="actionModeCloseButtonStyle">@style/ActionButton.CloseMode.xotab</item>
</style>

<style name="ActionBar.Solid.xotab" parent="@style/Widget.Sherlock.Light.ActionBar.Solid">
    <item name="background">@drawable/ab_solid_xotab</item>
    <item name="backgroundStacked">@drawable/ab_stacked_solid_xotab</item>
    <item name="backgroundSplit">@drawable/ab_bottom_solid_xotab</item>
    <item name="progressBarStyle">@style/ProgressBar.xotab</item>
</style>

<style name="ActionBar.Transparent.xotab" parent="@style/Widget.Sherlock.Light.ActionBar">
    <item name="background">@drawable/ab_transparent_xotab</item>
    <item name="progressBarStyle">@style/ProgressBar.xotab</item>
</style>

<style name="PopupMenu.xotab" parent="@style/Widget.Sherlock.Light.ListPopupWindow">
    <item name="android:popupBackground">@drawable/menu_dropdown_panel_xotab</item>
</style>

<style name="DropDownListView.xotab" parent="@style/Widget.Sherlock.Light.ListView.DropDown">
    <item name="android:listSelector">@drawable/selectable_background_xotab</item>
</style>

<style name="ActionBarTabStyle.xotab" parent="@style/Widget.Sherlock.Light.ActionBar.TabView">
    <item name="android:background">@drawable/tab_indicator_ab_xotab</item>
</style>

<style name="DropDownNav.xotab" parent="@style/Widget.Sherlock.Light.Spinner.DropDown.ActionBar">
    <item name="android:background">@drawable/spinner_background_ab_xotab</item>
    <item name="android:popupBackground">@drawable/menu_dropdown_panel_xotab</item>
    <item name="android:dropDownSelector">@drawable/selectable_background_xotab</item>
</style>

<style name="ProgressBar.xotab" parent="@style/Widget.Sherlock.Light.ProgressBar.Horizontal">
    <item name="android:progressDrawable">@drawable/progress_horizontal_xotab</item>
</style>

<style name="ActionButton.CloseMode.xotab" parent="@style/Widget.Sherlock.Light.ActionButton.CloseMode">
    <item name="android:background">@drawable/btn_cab_done_xotab</item>
</style>

<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.xotab.Widget" parent="@style/Theme.Sherlock">
    <item name="popupMenuStyle">@style/PopupMenu.xotab</item>
    <item name="dropDownListViewStyle">@style/DropDownListView.xotab</item>
</style>

Solution

  • You can do this via code in an easier way in onCreate:

    int titleId = Resources.getSystem().getIdentifier("action_bar_title", "id", "android");
    TextView Tv = (TextView)findViewById(titleId);
    Tv.setTextColor(colorID);