6

I wants to change the action bar title color to white in android . and i am using theme in values Theme.AppCompat.Light and values-14 Theme.AppCompat.Light.DarkActionBar
I have tried so far in values folder :

<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
    <item name="actionBarStyle">@style/MyActionBar</item>
</style>

<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
    <item name="android:textColor">@android:color/white</item>
</style>

and values -14 folder

  <style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="actionBarStyle">@style/MyActionBar</item>
</style>

<!-- ActionBar styles -->
<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
    <item name="android:textColor">@android:color/white</item>
</style>

but ActionBar title color is not changing.

reVerse
  • 35,075
  • 22
  • 89
  • 84
John
  • 1,407
  • 7
  • 26
  • 51

3 Answers3

5

You can specify the background color of the ActionBar by using the colorPrimary attribute; something like the following:

    <style name="AppBaseTheme" parent="Theme.AppCompat.Light">
    <item name="colorPrimary">@android:color/white</item>
    </style>

The above is a special tag created for AppCompat; you will notice that the android: namespace is omitted.

Willis
  • 5,308
  • 3
  • 32
  • 61
  • 3
    The question was changing the text color not the background color. Yes you can set `colorPrimary` on AppCompat similar to Material action bar, but you can't set `textColorPrimary` in the same regard, which is why he is asking the question. – Jason Hu Mar 30 '15 at 01:26
  • 1
    Question asks the method to change actionbar text color, not the color of action bar itself. – sahil shekhawat Jun 05 '15 at 08:43
1

If you are using Theme.AppCompat.Light.NoActionBar do

<android.support.v7.widget.Toolbar  xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:minHeight="?attr/actionBarSize"
    android:background="@color/background_material_dark"
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
vintuwei
  • 788
  • 8
  • 7
0

You should also check that in you layout xml file you don't have an android:theme attribute specified, which would have priority over the main theme

DoruChidean
  • 7,941
  • 1
  • 29
  • 33