2016-11-26 171 views
5

基于this tutorialthis answer,其中还引用this other tutorial,使用主题的android:windowBackground<layer-list/>一起似乎是最批准创建的Android开机画面可以将WindowBackground放置在状态栏下方并位于导航栏上方吗?

使用该技术中心在屏幕上标识的方法很简单;不过,我想要沿着屏幕的顶部或底部定位图形。我遇到了问题,因为在下面的屏幕截图中看到,windowBackground似乎在屏幕顶部的状态栏和底部的导航栏后面绘制,从而使图形显示截止



问:是否有可能指示windowBackground摆正自己的位置下方的状态栏和导航栏上方?如果没有,使用windowBackground启动屏幕技术可以创建一个不包含在状态栏或导航栏中的启动画面?

要重现该问题,创建一个新的Android Studio项目,这将让你的ic_launcher绘制,并按照上面链接的教程之一,但使用以下layer-list绘制

<?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

你可以设置windowDrawsSystemBarBackgroundsfalse在你的主题为棒棒糖和更高版本。

例: 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> 
+0

这工作完全根据需要,谢谢你。 – konata