在我们打开APP的时候,总是会删一下白屏,或者黑屏,所以今天针对这个问题做一下自己的见解。
为什么在启动APP时,会出现白屏或者黑屏那?
其实出现黑白屏并不是不正常的,而是没有加载到布局文件,就已经显示window窗口背景,
黑屏白屏就是window窗口背景,
解决黑白屏问题的办法
在mainfeist.xml文件 针对window主题 theme设置背景 windowBackground,就可以解决黑白屏问题
解决方案:
1.通过设置style
设置背景Theme,设置一张背景图,首页显示就这张背景图。避免出现黑屏
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@mipmap/splash</item>
</style>
2.设置透明的Theme
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
</style>
这是两种解决办法。本人还是推荐使用透明的Threme,因为本公司的项目就是使用的透明方法;