Android应用启动白屏问题

近期在做一个小的Android应用,发现启动第一个Activity时,总会出现一个白屏,即“闪屏”,影响了APP体验,通过在AndroidManifest.xml中为Main Activity配置专属theme可以解决这个问题。

<?xml version=”1.0″ encoding=”utf-8″?>

    package=”com.example.xxxxx”>

        android:allowBackup=”true”

        android:icon=”@mipmap/ic_launcher”

        android:label=”@string/app_name”

        android:roundIcon=”@mipmap/ic_launcher_round”

        android:supportsRtl=”true”

        android:theme=”@style/Theme.AppCompat.Light.NoActionBar” ><!–此处修改APP全局主题,如添加标题栏–>>

<!–这里是启动页,配置专属的android.theme,可以解决白屏问题,styleSplashImage可以在style.xml中配置–>

        <activity android:name=”.Game” android:screenOrientation=”landscape” android:theme=”@style/styleSplashImage”>

            <intent-filter>

                <action android:name=”android.intent.action.MAIN” />

                <category android:name=”android.intent.category.LAUNCHER” />

            </intent-filter>

        </activity>

    </application>

</manifest>

styleSplashImage的配置如下

<style name=”styleSplashImage” parent=”Theme.AppCompat.Light.NoActionBar”>

        <item name=”android:windowIsTranslucent”>true</item>

        <item name=”android:windowNoTitle”>true</item>

    </style>

亲证有效,参考:

https://blog.csdn.net/qq_29266921/article/details/54342977

    原文作者:斯沃勒科教工作室
    原文地址: https://www.jianshu.com/p/e206e4eecd8a
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞