Can a WindowBackground be placed below the status bar and above the navigation bar?

Based on this tutorial and this answer , which also links to this other tutorial using the android:windowBackground along with <layer-list/> , is apparently the most approved method for creating an Android splash screen

Using this technique to center the logo on the screen is very simple; however, I want to arrange the graphics along the top or bottom of the screen. I ran into problems because, as can be seen in the screenshot below, windowBackground appears both for the status bar at the top of the screen and the navigation bar at the bottom, which makes the graphics disabled



Question: Is it possible to instruct windowBackground position itself below the status bar and above the navigation bar? If not, using the windowBackground Splash Screen technique, can I create a splash screen that is not covered by the Status Bar or the navigation bar?

To reproduce the problem, create a new project for Android Studio that will provide you with ic_launcher drawable and follow one of the above tutorials, but use the following layer-list drawable

 <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:opacity="opaque"> <item android:drawable="#000000"/> <item> <bitmap android:gravity="left|top" android:src="@drawable/ic_launcher"/> </item> <item> <bitmap android:gravity="center" android:src="@drawable/ic_launcher"/> </item> <item> <bitmap android:gravity="bottom" android:src="@drawable/ic_launcher"/> </item> </layer-list> 
+6
source share
1 answer

You can set windowDrawsSystemBarBackgrounds to false in your theme for candies and higher versions.

Example: RES / values-V21 / styles.xml

 <?xml version="1.0" encoding="utf-8"?> <resources xmlns:android="http://schemas.android.com/apk/res/android"> <style name="Theme.Splash"> <item name="android:windowBackground">@drawable/splash</item> <item name="android:windowDrawsSystemBarBackgrounds">false</item> </style> </resources> 
+7
source

Source: https://habr.com/ru/post/1012670/


All Articles