0

Okay so following Googles Developers guide I've tried (and failed) to change the color of the implemented actionbar. I'm currently using Android Studio instead of eclipse and have just updated everything to the recent release.

I'm essentially trying to change the color of the actionbar to anything but the default "light" color.

Here's some lovely code.

values/styles.xml

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light">
    </style>

</resources>

values-v21/styles.xml

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

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

    <style name="MyActionBar" parent="Widget.AppCompat.Light.ActionBar">
        <item name="android:background">#ff0000</item>
    </style>

</resources>

Any help appreciated thanks.

  • The only thing you have to do is to add `#ff0000` to your AppTheme. See [this post(click)](http://stackoverflow.com/questions/26435684/change-material-design-appcompat-actionbar-color/26450406#26450406) for more info. – reVerse Nov 04 '14 at 20:06
  • possible duplicate of [How to set custom ActionBar color / style?](http://stackoverflow.com/questions/18288402/how-to-set-custom-actionbar-color-style) – Philipp Jahoda Nov 04 '14 at 20:18
  • '#ff0000' only works on API level 21. I need answer for API level 11 + or better yet 7+ – Alex Knight Nov 04 '14 at 20:58
  • You're using the `appcompat-v7` so this will work on all API levels starting with 7. – reVerse Nov 04 '14 at 21:13

1 Answers1

0

You can try this by coding if you want

ActionBar ab = getActionBar();
ab.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#ff0000")));
NightShadeQueen
  • 3,284
  • 3
  • 24
  • 37
Rutvik
  • 137
  • 1
  • 1
  • 9