0

I want to change the color of the title bar. I tried this:

<style name="AppTheme" parent="AppBaseTheme">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    <item name="android:actionBarStyle">@style/ColorBar</item>
</style>

<style name="ColorBar" parent="@android:style/Widget.Holo.Light.ActionBar">
    <item name="android:background">@color/white</item>
    <item name="android:textColor">@color/orange</item>
</style>

But it doesn't work. What is wrong in my code shown above?

EDIT : it's the color of the text i want to change, not the background (it's running for the background)

deveLost
  • 1,151
  • 2
  • 20
  • 47

5 Answers5

2

This should work for all devices, you will need the support library (appcompat_v7)

<style name="Theme" parent="@style/BaseTheme"></style>

<style name="BaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="actionBarStyle">@style/ActionBar</item>
    <item name="android:actionBarStyle">@style/ActionBar</item>
</style>

<style name="ActionBar" parent="@style/Widget.AppCompat.Light.ActionBar">
    <item name="android:background">@color/orange </item>
    <item name="background">@color/orange </item>
    <item name="android:titleTextStyle">@style/ActionBar.Text</item>
    <item name="titleTextStyle">@style/ActionBar.Text</item>
</style>

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

manifest :

 android:theme="@style/Theme"
ElDuderino
  • 3,253
  • 2
  • 21
  • 38
0

Does changing the parent to parent="@android:style/Widget.Holo.Light.ActionBar.Solid" make a difference?

If not, let me know what happens if you move the

<item name="android:actionBarStyle">@style/ColorBar</item> into the AppBaseTheme style


Try setting all of these:

    <item name="android:background">@color/something</item>
    <item name="android:backgroundStacked">@color/something</item>
    <item name="android:backgroundSplit">@color/something</item>
Nyx
  • 2,233
  • 1
  • 12
  • 25
0

There may be problem with the android version. You should consider old ones and new ones. Try adding these both lines for different versions.

<item name="android:background">@drawable/your_color</item>
<item name="background">@drawable/your_color</item>
eluleci
  • 3,489
  • 1
  • 26
  • 24
  • there is a mistake, it's not the background i want to change, but the text in the title bar, i'm sorry. – deveLost May 22 '14 at 08:32
0

This is an easy way for settings the color of the actionbar-title by Java

getActionBar().setTitle(Html.fromHtml("<font color=\"#ffffff\">" + "TITLE" + "</font>"));

If you're using a support library, then you can use getSupportActionBar();.

timbillstrom
  • 1,176
  • 16
  • 33
0

I'm new to all of this but I found it easier to go to Res > Value > colors.xml and from there you can change the "primary color." This changed the title bar to the color I selected.