Android 应用启动时解决白屏问题

这是由application默认主题导致的;解决思路:
1在其主题中加上windowBackground属性即可
2可以继承其默认主题,重写其主题背景(windowBackground);
思路1解决

 <!-- Base application theme. -->
    <style name="AppTheme" parent="android:Theme.Holo.Light.NoActionBar.Fullscreen">
        <!-- Customize your theme here. -->
        <item name="android:windowBackground">@drawable/ic_launcher_background</item>
    </style>

思路2解决

之前:

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/Theme.AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>

解决

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="android:Theme.Holo.Light.NoActionBar.Fullscreen">
        <!-- Customize your theme here. -->
    </style>
    <style name="Theme.MyAppTheme" parent="AppTheme">
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowBackground">@drawable/ic_launcher_background</item>
        <item name="android:windowFullscreen">true</item>
    </style>

</resources>
<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/Theme.MyAppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>

猜你喜欢

转载自blog.csdn.net/xiyangyang8110/article/details/80203409