基于this tutorial和this answer,也引用了this other tutorial,使用主题android:windowBackground
和<layer-list/>
似乎是最受批准的方法创建Android启动画面
使用这种技术将徽标集中在屏幕上很容易;但是,我想在屏幕的顶部或底部放置图形。我遇到了问题,因为如下面的屏幕截图所示,windowBackground
似乎被绘制在屏幕顶部的状态栏和底部的导航栏后面,从而使图形看起来像是 - 关
问题: 是否可以指示windowBackground
将自己定位在状态栏下方和导航栏上方?如果没有,使用windowBackground
启动画面技术是否可以创建状态栏或导航栏未涵盖的启动画面?
要重现此问题,请创建一个新的Android Studio项目,该项目将为您提供ic_launcher
drawable并按照上面链接的其中一个教程但使用以下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>
答案 0 :(得分:13)
您可以在主题中为棒棒糖及更高版本设置windowDrawsSystemBarBackgrounds
至false
。
实施例: RES /值-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>