1、需求:Android app 啓動時 總是黑屏或者白屏 1秒鐘 產品 要去改進 體驗、
於是 再 啓動頁 添加了 新的style 配置 成功解決 問題
代碼如下:manifest 中app 啓動頁 :
<activity android:name=".WelcomeActivity"
android:theme="@style/welcome">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
劃重點:
android:theme="@style/welcome"
style 文件中添加:
<style name="welcome" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowBackground">@drawable/splash_drawable</item>
<!-- <item name="android:windowTranslucentStatus">true</item>-->
<item name="android:windowFullscreen">true</item>
</style>
splash_drawable 文件內容:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />
<item>
<bitmap
android:gravity="bottom"
android:scaleType="centerCrop"
android:src="@drawable/splash"
android:tileMode="disabled" />
</item>
</layer-list>
需要一張 初始化的整體圖片 splash 放在drawable 文件夾下。
如果解決了你的問題 麻煩點個贊謝謝