0

Hello I am noob in Android.

I am using appcompat support library to make my application backward compatible. Here action bar color is Light by default I want to change the background color to my custom color.

Any idea how to do this ??

styles.xml

<resources>

    <!--
        Base application theme, dependent on API level. This theme is replaced
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
    -->
    <style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light">
        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
        -->
    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    </style>

</resources>

enter image description here

Mick
  • 1,179
  • 5
  • 14
  • 24
  • 1
    Check this http://stackoverflow.com/questions/8024706/how-do-i-change-the-background-color-of-the-actionbar-of-an-actionbaractivity-us – Zohra Khan Apr 17 '14 at 13:44

3 Answers3

1

This solved my problem. Thanks @Zohra

ActionBar mActionBar = getActionBar();
mActionBar.setBackgroundDrawable(new ColorDrawable("COLOR"));
Mick
  • 1,179
  • 5
  • 14
  • 24
0

You can try to use an approach from official documentation. I think it has clear example how to do it.

olegr
  • 1,999
  • 18
  • 23
0

your style might look like this

reference:- https://developer.android.com/training/basics/actionbar/styling.html

  <style name="CustomActionBarTheme"
       parent="@style/Theme.AppCompat.Light">

    <!-- Support library compatibility -->
    <item name="actionBarStyle">@style/MyActionBar</item>
  </style>

<!-- ActionBar styles -->
<style name="MyActionBar"
       parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">

    <!-- Support library compatibility -->
    <item name="background">@drawable/actionbar_background</item>
</style>
mha90
  • 181
  • 6