转自:解决 Android APP 启动页白屏问题及如何实现全屏显示_android 启动白屏-优快云博客
一、白屏原因分析
其实,白屏现象很容易理解,在冷启动一个 APP 的时候,启动页还没完成布局文件的加载,此时显示的是 Window 窗口背景,我们看到的白屏就是 Window 窗口背景。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 在加载布局之前,显示的是 window 的背景
setContentView(R.layout.activity_launcher);
}
Window 背景的是由 Application theme 决定的,通过设置 AndroidManifest.xml 文件里面 <application> 属性实现:
android:theme="@style/AppTheme"
如下所示:背景色是白色背景,启动时就会显示白屏。
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">