2017-02-26 186 views
2

我正尝试用这篇文章为android应用程序创建初始屏幕:Splash Screens the Right Way。正如文章所说,我创建了具有两层的LayerDrawable:背景位图和徽标(也是位图)。例如,徽标需要位于屏幕底部,缩进32dp。这里我绘制:安卓半透明状态栏,但非半透明导航栏(如果有)

<item 
    android:drawable="@drawable/splash_image" /> 

<item 
    android:id="@+id/logo" 
    android:bottom="@dimen/margin_splash"> 

    <bitmap 
     android:gravity="bottom|center" 
     android:src="@drawable/logo_green" /> 
</item> 

我指出这一点可绘制在我的飞溅活动主题android:windowBackground PARAM。我还希望在支持此功能的设备上显示启动画面时,透明状态栏(API> = 19),因此我为不同的android版本创建了两个资源文件,并在values-v19 \ styles.xml中创建了两个资源文件,我标记为android:windowTranslucentStatus这是真的。这里我values/styles.xmlvalues-v19/styles.xml

值/ styles.xml

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
     <item name="android:windowBackground">@drawable/bg_splash</item> 
    </style> 
</resources> 


值-V19/styles.xml

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
     <item name="android:windowBackground">@drawable/bg_splash</item> 
     <item name="android:windowTranslucentStatus">true</item> 
    </style> 
</resources> 

但在一些带有软导航栏Android设备我的标志与它重叠。 Logo overlapping by NavigationBar
我试图指出android:windowTranslucentNavigation标志为假但没有成功。

是否有任何方法使Android软件NavigationBar与透明状态栏一起透明,或者我需要在我的splash活动的onCreate方法中检测Soft NavigationBar可用性,并通过向NavigationBar的高度添加徽标的底部缩进来更新我的LayerDrawable?

感谢。

回答

0

你试过这个吗?

<item name="android:navigationBarColor">@android:color/transparent</item> <item name="android:windowTranslucentStatus">false</item> <item name="android:windowTranslucentNavigation">false</item> 

此外,您可以在图层可绘制的位图项中填充一个小底部。

0

我遇到了同样的问题,并通过设置下列属性来解决此问题。

<item name="android:windowDrawsSystemBarBackgrounds">false</item> 

该属性设置为values-v21目录。