Android APP去除啟動頁出現的黑色閃現
阿新 • • 發佈:2018-12-25
Android APP在啟動的時候,會有預設的一個黑色預啟動背景,如果啟動頁是亮色的,十分影響視覺。我們只需要設定SplashActivity的Theme就可以了。方案有三種:
設定一張圖
<style name="Theme.AppStartLoad" parent="android:Theme.NoTitleBar.Fullscreen"> <item name="android:windowBackground">@drawable/splash_background</item> <item name="android:windowNoTitle">true</item> </style>
這樣的體驗很好,點選App後直接就顯示了需要的預設啟動圖片,但是如果我們的APP啟動頁大圖會根據服務端策略變化,這樣的方案就不行了。
透明背景
<style name="Theme.AppStartLoad" parent="android:Theme.NoTitleBar.Fullscreen"> <item name="android:windowNoTitle">true</item> <item name="android:windowIsTranslucent">true</item> </style>
這樣就可以避免黑色的閃現了,但是在有些低端手機上面,Launcher會跳動一下,相容性貌似不很好。
去掉預啟動背景
<style name="Theme.AppStartLoad" parent="android:Theme.NoTitleBar.Fullscreen">
<item name="android:windowNoTitle">true</item>
<item name="android:windowDisablePreview">true</item>
</style>
推薦使用這個方法來去掉啟動的黑色閃現
關於Android的系統內建Theme具體可以參考這篇文章:
http://developer.android.com/guide/topics/ui/themes.html#PlatformStyles