Color status bar in android screensaver

I added a splash screen to my Android app, and I would like the status indicator to display color when displayed.

This is the contents of the file under drawable:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@color/colorPrimary" /> <item> <bitmap android:gravity="center" android:src="@mipmap/ic_home"/> </item> </layer-list> 

and I added this style:

 <style name="SplashTheme" parent="Theme.AppCompat.NoActionBar"> <item name="android:windowBackground">@drawable/splashscreen</item> </style> 
+5
source share
2 answers

Adding a colorPrimaryDark element to your theme should do the trick:

 <style name="SplashTheme" parent="Theme.AppCompat.NoActionBar"> <item name="android:windowBackground">@drawable/splashscreen</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> </style> 
+7
source
  if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); getWindow().setStatusBarColor(getResources().getColor(R.color.colorPrimaryDark)); } 
+1
source

All Articles