StatysBar color setting method

Method one:

In styles. XML set the value of “colorPrimaryDark” :
<resources> <! -- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <! -- Customize your theme here. --> <item name="colorPrimaryDark">@color/mainColor</item> </style> </resources>Copy the code

Method 2:

Set the value of “statusBarColor” in styles. XML:
<resources> <! -- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <! -- Customize your theme here. --> <item name="android:statusBarColor">@android:color/black</item> </style> </resources>Copy the code

2. ColorPrimaryDark and statusBarColor

Difference:

-1. StatusBarColor has a higher priority and overwrites colorPrimaryDark when two of them appear at the same time.

-2. StatusBarColor will be warned in Android5.0 or later.

-3. By default, the value of statusBarColor inherits from colorPrimaryDark.