Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Material Design AppCompat ActionBar Color

I used to change AppCompat status bar color with actionBarStyle, and creating a style with a background which is the color I want.

Now, with Material Design AppCompat, this method doesn't work anymore.

Can you help me? Thanks.

like image 458
user3184899 Avatar asked Oct 18 '14 02:10

user3184899


People also ask

How can I change the color of my top bar in Android?

Step 1: After opening the android studio and creating a new project with an empty activity. Step 2: Navigate to res/values/colors. xml, and add a color that you want to change for the status bar.


1 Answers

There's a new attribute called colorPrimary which you can define in your Theme. This will give you ActionBar or Toolbar a solid color.

Following a little example:

<style name="AppTheme" parent="Theme.AppCompat.Light">     <!-- colorPrimary is used for the default action bar background -->     <item name="colorPrimary">@color/my_action_bar_color</item> </style> 

Please note: It has to be only colorPrimary, not android:colorPrimary, in every values-folder except the values-v21 one.

You can read more about customizing the Color Palette on developer.android.com.

like image 131
reVerse Avatar answered Sep 20 '22 10:09

reVerse