天天看點

Android 處理啟動頁(Splash)白屏問題

Android 處理啟動頁(Splash)白屏問題,做一下記錄:

一、在drawable檔案夾下的一個定義樣式中使用的xml背景splash_bg.xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<bitmap android:gravity="fill" android:src="@drawable/white" />
</item>
<item>
<bitmap android:gravity="center" android:src="@drawable/splash" />
</item>
<item>
<bitmap android:gravity="bottom|center" android:src="@drawable/splash_bottom" />
</item>
</layer-list> 
           

二、定義樣式@style/Theme.Splash:

<style name="Theme.Splash" parent="@style/AppTheme">
<item name="android:windowBackground">@drawable/splash_bg</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowAnimationStyle">@style/noAnimation</item>
<item name="android:windowFullscreen">true</item>
</style>
           

三、最後在AndroidManifest.xml引用:

android:theme="@style/Theme.Splash</span>"
           

雖然看起來的挺簡單的,但是處理了白屏問題後,可以明顯的提高使用者的體驗性!