Просмотр исходного кода

App启动优化,告别启动白黑屏

zhanghai лет назад: 8
Родитель
Сommit
5082468c6f

+ 1 - 1
app/src/main/AndroidManifest.xml

@@ -200,7 +200,7 @@
 
         <activity android:name="com.sheep.gamegroup.view.activity.SplashAct"
             android:screenOrientation="portrait"
-            android:theme="@style/FullScreenTheme"
+            android:theme="@style/SplashTheme"
             >
             <intent-filter>
                 <action android:name="android.intent.action.MAIN"/>

+ 8 - 0
app/src/main/java/com/sheep/gamegroup/view/activity/SplashAct.java

@@ -13,6 +13,7 @@ import android.os.Handler;
 import android.os.Message;
 import android.provider.Settings;
 import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
 import android.support.v7.app.AlertDialog;
 import android.text.TextUtils;
 import android.view.View;
@@ -64,6 +65,13 @@ public class SplashAct extends BaseActivity implements SplashContract.View, Easy
     };
 
     @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        //恢复成默认主题
+        setTheme(R.style.FullScreenTheme);
+        super.onCreate(savedInstanceState);
+    }
+
+    @Override
     protected void onStart() {
         super.onStart();
         requestCodePermissions();

+ 6 - 0
app/src/main/res/values/styles.xml

@@ -12,6 +12,7 @@
         <item name="android:windowBackground">@color/translate</item>
         <item name="android:windowIsTranslucent">true</item>
     </style>
+
     <!--全屏-->
     <style name="FullScreenTheme" parent="Trans">
         <item name="android:windowFullscreen">true</item>
@@ -24,6 +25,11 @@
         <item name="android:windowIsTranslucent">true</item>
     </style>
 
+    <!--快速启动app主题,告别app启动黑白屏-->
+    <style name="SplashTheme" parent="FullScreenTheme">
+        <item name="android:windowBackground">@drawable/splash_bg_img</item>
+        <item name="android:windowIsTranslucent">false</item>
+    </style>
 
     <style name="aaa" parent="Theme.AppCompat.Light.NoActionBar">
         <!-- Customize your theme here. -->