Android Studio Action Bar Color not Changing

android, android-5.0-lollipop, android-studio, xml

Solution

UPDATE:

Make a new file in your layouts folder called tool_bar.xml and paste the following code:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:background="@color/ColorPrimary"
    android:elevation="2dp"
    android:theme="@style/Base.ThemeOverlay.AppCompat.Dark"
    xmlns:android="http://schemas.android.com/apk/res/android" />

Add these colors in your color.xml file:

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <color name="ColorPrimary">#00897B</color>
    <color name="ColorPrimaryDark">#00695C</color>

</resources>

This is the code for your styles.xml file:

<resources>

   <!-- Base application theme. -->
   <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
       <item name="colorPrimary">@color/ColorPrimary</item>
       <item name="colorPrimaryDark">@color/ColorPrimaryDark</item>
   </style>

You should add the folowing code to your MainActivity.xml file:

<include
    android:id="@+id/tool_bar"
    layout="@layout/tool_bar"
    android:layout_height="wrap_content"
    android:layout_width="match_parent" />

This way worked for me!

This should give you the actionbar that looks like the one below a result

Problem

in styles.xml running Android 5.0 lollipop ``` <resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="android:colorPrimary">@color/primary</item> <item name="android:colorPrimaryDark">@color/primary_dark</item> <item name="android:colorAccent">@color/accent</item> <item name="android:statusBarColor">@color/primary</item> <item name="android:colorAccent">@color/accent</item> <item name="android:textColorPrimary">@color/primary_text</item> <item name="android:textColor">@color/secondary_text</item> <item name="android:navigationBarColor">@color/primary_dark</item> </style> ``` when I build it and run it, I only get the status bar colored with the colorPrimaryDark while the toolbar remains black. How do I make it turn to colorPrimary? This is what I'm currently getting https://www.dropbox.com/s/alp8d2fhzfd5g71/Screenshot_2015-02-25-21-13-01.png?dl=0

Original source