美文网首页
关于AndroidAPP启动时发生白屏问题的解决

关于AndroidAPP启动时发生白屏问题的解决

作者: 晓风残月酒醒 | 来源:发表于2017-07-20 18:24 被阅读0次

别废话了,直接上代码:
1.manifest.xml中设置主题:

        <activity
            android:name="com.zack.ownerclient.SplashActivtiy"
            android:screenOrientation="portrait"
            android:theme="@style/SplashTheme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

2.styles中准备该主题:

   <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:windowDrawsSystemBarBackgrounds">false</item><!--解决华为虚拟键盘遮住问题-->
    </style>

    <style name="SplashTheme" parent="AppTheme">
        <!-- 解决启动白屏的问题 -->
        <item name="android:windowBackground">@drawable/theme_splash</item>
        <item name="android:windowFullscreen">true</item>
    </style>

3.准备好这个drawable:theme_splash.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- 背景颜色 -->
    <item android:drawable="@drawable/img_start_bg" />
    <item >
        <bitmap
            android:gravity="center"
            android:id="@+id/bitmap_splash"
            android:src="@drawable/img_start_logo">
        </bitmap>
    </item>
</layer-list>
具体效果.PNG

相关文章

网友评论

      本文标题:关于AndroidAPP启动时发生白屏问题的解决

      本文链接:https://www.haomeiwen.com/subject/uxejkxtx.html