1,在setContentView,去掉标题栏 状态栏
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
2,使用handler的postDelay方法执行延迟的跳转到MainActivity
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
//停止 的时候跳转到MainActivity
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
},1000);
3,去掉setContentView
因为是setContentView在加载视图的时候造成的黑屏和白屏
4,给SplashActivity设置无ActionBar的主题,并在背景中添加background的视图
<style name="AppTheme_FullScreen" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="android:windowBackground">@drawable/welcome</item>
</style>