解决app进入的白屏问题

2019-01-20  本文已影响0人  魔鬼王中王

我们采用透明背景来实现:

1.先在values文件夹下的style中添加一个主题

<!--SplashActivity Theme-->
    <style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowIsTranslucent">true</item>  <!-- 透明背景 -->
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowBackground">@color/white</item>
        <item name="android:windowFullscreen">true</item>
    </style>

2.在清单文件启动页splashActivity设置代码

<activity
            android:name=".ui.SplashActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:launchMode="singleTask"
            android:screenOrientation="portrait"
            android:theme="@style/SplashTheme"
            android:windowSoftInputMode="stateHidden|adjustPan">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

ok,大功告成!!!

上一篇 下一篇

猜你喜欢

热点阅读