Skip to content Skip to sidebar Skip to footer

How To Change Programmatically Background Color Of Action Bar Items

It is easy to set a default color of the items background in action bar by setting: @drawable/action_bar_item_background

Solution 1:

Have you tried the solution from user3225831 mentioned here: https://stackoverflow.com/a/21297231/1738838

ActionBarbar= getActionBar();
bar.setBackgroundDrawable(newColorDrawable("COLOR")); 

Solution 2:

Use simple one line code... Pass RGB values of the required color

getActionBar().setBackgroundDrawable(new ColorDrawable(Color.rgb(248, 248, 248)));

For Color codes, you can use this website: http://www.rapidtables.com/web/color/RGB_Color.htm

Solution 3:

I have found a simple workaround of this problem. You can set transparent color to the background of action bar item. Then changing color of the action bar will change background of the item. I don't see possibility to change item color without recreating an the activity.

Post a Comment for "How To Change Programmatically Background Color Of Action Bar Items"