産生原因
之是以會顯示黑屏或者白屏是因為還沒加載到布局檔案,就已經顯示了window視窗背景,黑屏白屏就是window視窗背景
解決辦法
設定style,在主題中加入以下屬性:
true
如果是進入app的歡迎頁出現這種情況還可以設定一個預設的背景圖如下:
@mipmap/splash
true
true
之後隻需要在AndroidManifest.xml中設定改主題就可以了
常見的主題
android:theme="@android:style/Theme.Dialog" //Activity顯示為對話框模式
android:theme="@android:style/Theme.NoTitleBar" //不顯示應用程式标題欄
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" //不顯示應用程式标題欄,并全屏
android:theme="Theme.Light " //背景為白色
android:theme="Theme.Light.NoTitleBar" //白色背景并無标題欄
android:theme="Theme.Light.NoTitleBar.Fullscreen" //白色背景,無标題欄,全屏
android:theme="Theme.Black" //背景黑色
android:theme="Theme.Black.NoTitleBar" //黑色背景并無标題欄
android:theme="Theme.Black.NoTitleBar.Fullscreen" //黑色背景,無标題欄,全屏
android:theme="Theme.Wallpaper" //用系統桌面為應用程式背景
android:theme="Theme.Wallpaper.NoTitleBar" //用系統桌面為應用程式背景,且無标題欄
android:theme="Theme.Wallpaper.NoTitleBar.Fullscreen" //用系統桌面為應用程式背景,無标題欄,全屏
android:theme="Theme.Translucent" //透明背景
android:theme="Theme.Translucent.NoTitleBar" //透明背景并無标題
android:theme="Theme.Translucent.NoTitleBar.Fullscreen" //透明背景并無标題,全屏
android:theme="Theme.Panel " //面闆風格顯示
android:theme="Theme.Light.Panel" //平闆風格顯示