版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/luzhiquanandroid/article/details/85200407
1.解决app启动白屏问题 介绍两种方式
-
加载首页页面前,进行页面或者颜色过渡,用户体验感好
第一步设置一下主题色为透明<!-- 应用启动页(StartingWindow)的theme --> <style name="AppTheme.StartingWindowTheme" parent="AppTheme"> <item name="android:windowIsTranslucent">true</item> </style>
第二步,在启动的activity设置一下主题theme
<activity android:name=".ui.activity.NavigationActivity" android:theme="@style/AppTheme.StartingWindowTheme" android:screenOrientation="portrait"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
第三布,在加载完成页面的时候,设置为以前的theme
override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) { super.onCreate(savedInstanceState, persistentState) setTheme(R.style.AppTheme)//恢复原有的样式 }
-
加载首页页面前,进行透明显示,点击桌面图标,卡顿一下进入首页
第一步设置一下主题 为一张图片背景或者颜色
<!-- 应用启动页(StartingWindow)的theme --> <style name="AppTheme.StartingWindowTheme" parent="AppTheme"> <!-- 可以设置成纯颜色(设置一个和Activity UI相似的背景) --> <!--<item name="android:windowBackground">@color/blue_home</item>--> <!--也可以设置成一张图片 --> <!--<item name="android:windowBackground">@drawable/bgbg</item>--> </style>
第二步和第三步一样
-
参考文档
http://ju.outofmemory.cn/entry/356791
http://www.cnblogs.com/whycxb/p/9312914.html