Android Studio screen color does not change

in styles.xml running Android 5.0 lollipop

<resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="android:colorPrimary">@color/primary</item> <item name="android:colorPrimaryDark">@color/primary_dark</item> <item name="android:colorAccent">@color/accent</item> <item name="android:statusBarColor">@color/primary</item> <item name="android:colorAccent">@color/accent</item> <item name="android:textColorPrimary">@color/primary_text</item> <item name="android:textColor">@color/secondary_text</item> <item name="android:navigationBarColor">@color/primary_dark</item> </style> 

when I create and run it, I get only the status bar colored with the color PrimaryDark, while the toolbar remains black. How to make it access colorPrimary?

This is what I'm getting right now

https://www.dropbox.com/s/alp8d2fhzfd5g71/Screenshot_2015-02-25-21-21-13-01.png?dl=0

+2
source share
3 answers

UPDATE:

Create a new file in the layouts folder named tool_bar.xml and paste the following code:

 <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.Toolbar android:layout_height="wrap_content" android:layout_width="match_parent" android:background="@color/ColorPrimary" android:elevation="2dp" android:theme="@style/Base.ThemeOverlay.AppCompat.Dark" xmlns:android="http://schemas.android.com/apk/res/android" /> 

Add these colors to your color.xml file:

 <?xml version="1.0" encoding="utf-8"?> <resources> <color name="ColorPrimary">#00897B</color> <color name="ColorPrimaryDark">#00695C</color> </resources> 

This is the code for the styles.xml file:

 <resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <item name="colorPrimary">@color/ColorPrimary</item> <item name="colorPrimaryDark">@color/ColorPrimaryDark</item> </style> 

You must add the following code to the MainActivity.xml file:

 <include android:id="@+id/tool_bar" layout="@layout/tool_bar" android:layout_height="wrap_content" android:layout_width="match_parent" /> 

This method worked for me!

This should give you an action bar that looks like the one below the result

enter image description here

+8
source

set @ color / carribean in .xml style. This will make the entire screen with the Caribbean color, including the action bar. Then in each job xml set - android: background = "@ color / white". This will change the background of the activity, keeping the color of the action bar on the caribou.

0
source

You must create tool_bar.xml as shown above and copy this code. And since your application is for API 21, you should have two xml files, one of which is tool_bar.xml (v21). Whatever code you use in (v21), xml determines what will be displayed on your Lollipop device. No matter what code in the other xml determines what will be displayed on older devices

0
source

All Articles