现在启动页消除点击时的黑屏,自然比较简单的方法就是在 Theme 中设置背景了,这个应该都知道。
今天设置背景时,在有导航栏的手机上跑,发现底部的图片有一部分被导航栏遮盖了,就找了下原因。
被遮盖时的主题设置和图片设置。
<style name="LaunchTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@drawable/splash_bg</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:opacity="opaque">
<item>
<shape android:shape="rectangle">
<solid android:color="#ffffff" />
</shape>
</item>
<item>
<bitmap
android:gravity="bottom|center_horizontal"
android:src="@mipmap/splash_bg"
android:tileMode="disabled" />
</item>
</layer-list>
Activity 是继承的 AppCompatActivity。
经过在网上的一番查找,将继承的主题换了,Activity 也换为继承 Activity ,这次背景片在底部加载出来时,就在导航栏的上方,并且隐藏导航栏后,图片也随着向下移动。
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar.Fullscreen">
<item name="android:windowBackground">@drawable/splash_bg</item>
<item name="android:windowFullscreen">true</item>
</style>
有知道的请告诉下,谢谢。
启动页后,从全屏到非全屏页面的平滑过渡,只要在跳转前,加入下面的代码就好,让activity提前退出全屏
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);