Android Action Bar setting background color

 In Android Application if you don't customize the action bar then the default icon and background color is set , if you want to change the icon and background color for action bar then you need to customize the style inside the res directory of your android project .

In Code

// setting background color
ColorDrawable colorDrawable = new ColorDrawable(Color.parseColor("#ffff0000"));

//setting icon


Declare set of color constants inside the res/values/colors.xml

file : res/values/colors.xml
<?xml version="1.0" encoding="utf-8"?>
     <color name="Red">#FF0000</color>
     <color name="Green">#008000</color>
     <color name="Blue">#0000FF</color>
     <color name="LightGreen">#98BD49</color>
     <color name="Orange">#FA8400</color>
     <color name="Pink">#F50057</color>
     <color name="Yellow">#FFF0F0</color>
     <color name="Black">#000000</color>
     <color name="White">#FFFFFF</color>

Adding the below style inside the res/values/style.xml , res/values-v11/style.xml , res/values-v14/style.xml

<resources xmlns:android="">

    <!-- Application theme. -->
    <style name="AppTheme" parent="@android:style/Theme.Holo.Light.DarkActionBar">
        <item name="android:actionBarStyle">@style/MyActionBar</item>

    <!-- ActionBar styles -->
    <style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
        <item name="android:background">@color/Pink</item>


Inside manifest file for application tag set the theme property with above defined style name 


No comments:

Post a Comment