欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

解決Android應(yīng)用冷啟動(dòng)時(shí)出現(xiàn)的白屏問題的方法

 更新時(shí)間:2017年08月31日 09:38:28   作者:陽春面  
本篇文章主要介紹了解決Android應(yīng)用冷啟動(dòng)時(shí)出現(xiàn)的白屏問題的方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

Android 應(yīng)用冷啟動(dòng)時(shí),需要從Application開始啟動(dòng),加載時(shí)間就會(huì)比較長,容易出現(xiàn)白色或黑色閃屏,觀察一下手機(jī)上一些 其他APP 比如 微信、京東等就不存在這個(gè)現(xiàn)象。

原因分析

分析一下原因,其實(shí)是跟閃屏Activity的主題有關(guān),比如使用了Theme.AppCompat.Light.DarkActionBar主題的話,其中指定了windowBackground,所以背景就是白色的了。

復(fù)制代碼 代碼如下:

 <itemname="android:windowBackground">@color/background_material_light</item>

解決方案

設(shè)置Theme

我們需要在 manifest指定SplashActivity的theme

<activity
  android:name=".SplashActivity"
  android:theme="@style/AppTheme.Splash">
  ...
</activity>

設(shè)置 Style 背景圖片

<style name="AppTheme.Splash" parent="AppTheme">
  <item name="android:windowBackground">@mipmap/splash</item>
  <item name="android:windowNoTitle">true</item>
</style>

這個(gè)style只是用來做閃屏的主題,APP的默認(rèn)主題還是使用AppTheme

這種設(shè)置后默認(rèn)先是出現(xiàn)APP內(nèi)置的閃屏圖片,然后在SplashActivity中再動(dòng)態(tài)加載在線閃屏,最后進(jìn)入主界面。最終實(shí)現(xiàn)效果與京東的APP類似。

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論