Android APP去除启动页出现的黑色闪现

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yutao52shi/article/details/48972009

Android APP在启动的时候,会有默认的一个黑色预启动背景,如果启动页是亮色的,十分影响视觉。我们只需要设置SplashActivity的Theme就可以了。方案有三种:

设置一张图

<style name="Theme.AppStartLoad" parent="android:Theme.NoTitleBar.Fullscreen">
	<item name="android:windowBackground">@drawable/splash_background</item>
	<item name="android:windowNoTitle">true</item>
</style>

这样的体验很好,点击App后直接就显示了需要的默认启动图片,但是如果我们的APP启动页大图会根据服务端策略变化,这样的方案就不行了。

透明背景

<style name="Theme.AppStartLoad" parent="android:Theme.NoTitleBar.Fullscreen">
	<item name="android:windowNoTitle">true</item>
	<item name="android:windowIsTranslucent">true</item>
</style>

这样就可以避免黑色的闪现了,但是在有些低端手机上面,Launcher会跳动一下,兼容性貌似不很好。

去掉预启动背景

<style name="Theme.AppStartLoad" parent="android:Theme.NoTitleBar.Fullscreen">
	<item name="android:windowNoTitle">true</item>
	<item name="android:windowDisablePreview">true</item>
</style>

推荐使用这个方法来去掉启动的黑色闪现

关于Android的系统内置Theme具体可以参考这篇文章:
http://developer.android.com/guide/topics/ui/themes.html#PlatformStyles

猜你喜欢

转载自blog.csdn.net/yutao52shi/article/details/48972009