Change Android 5.0 Actionbar color

I’m working with the new Lollipop Material Design guidelines and would like to incorporate that nifty navigation drawer animation in my app. I’ve gotten that far, by using the android.support.v7.app.ActionBarDrawerToggle, but now I’m having difficulty changing the color of said action bar. It stays bright gray no matter what I set the theme to. How would one go about changing the color of the actionbar? This is what my app theme looks like:

//res/values/styles.xml
<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">

    <item name="android:actionBarStyle">@style/ActionBar</item>
    <item name="android:colorPrimary">@color/primaryDef</item>
    <item name="android:colorPrimaryDark">@color/primaryDarkDef</item>
    <item name="android:activatedBackgroundIndicator">@drawable/defbg</item>
    <item name="android:colorAccent">@color/primaryDef</item>
    <item name="android:navigationBarColor">@color/primaryDarkDef</item>

</style>

<style name="ActionBar" parent="android:Widget.ActionBar">
    <item name="android:background">@color/primaryDef</item>
</style>

  • Why Camera.setParameters(Camera.Parameters) does not work on Sony-Ericsson X10 and Droid?
  • ParseFile.cancel() not working - file keeps being downloaded
  • Opencv increasing accuracy of threshold
  • for file picker openFileChooser() method not calling WebChromeClient of Kitkat 4.4
  • Overlay or hide Toolbar on copy/cut selection
  • NFC: What is the difference between S-beam and Android beam?
  • Related posts:

    Failure Android-L
    startLeScan with 128 bit UUIDs doesn&#039;t work on native Android BLE implementation
    Ellipsize is not working
    Failed to rename directory tools to temp\ToolPackage.old01 in C:\android-sdk-windows
    How to get LTE signal strength in Android?
    How to enable Stay awake in the developer options using ADB?
  • How can I store a data structure such as a Hashmap internally in Android?
  • Getting Google Map Fragment in onCreateView using ActionBar tabs
  • WinDeath on notifyDataSetChanged()
  • Error getting response stream (ReadDone1): ReceiveFailure
  • SSL session not being reused in Android WebView
  • Android app uninstallation event for analytics
  • One Solution collect form web for “Change Android 5.0 Actionbar color”

    AppCompat does not use the android: prefixed attributes for the Material Theme color palette items per the migration guide to v21 by the author of AppCompat. Instead, just use the names themselves:

    <style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
    
        <item name="colorPrimary">@color/primaryDef</item>
        <item name="colorPrimaryDark">@color/primaryDarkDef</item>
        <item name="colorAccent">@color/primaryDef</item>
    
        <item name="android:navigationBarColor">@color/primaryDarkDef</item>
        <item name="android:activatedBackgroundIndicator">@drawable/defbg</item>
    </style>
    

    The Action Bar will be colored by colorPrimary.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.