美文网首页
splash启动白屏

splash启动白屏

作者: CreScert | 来源:发表于2019-08-05 10:18 被阅读0次

    这几天需求要求加一个splash界面,app都做完上线了,最后要求加一个启动页....(* ̄︶ ̄)

    本着完美的心加上后,发现打开APP(在后台清空的情况下),点击APP后,出现500ms-1s之间的白屏,之后才是splash界面。

    解决办法:
    1.删除splash界面的setContentView设置布局。
    2.在 \color{#ff0000}{drawable} 中创建一个 \color{#ff0000}{splash.xml}文件内容如下:

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
        <item>
            <bitmap android:id="@+id/bm_splash"
                android:src="@drawable/book_book">
            </bitmap>
        </item>
    </layer-list>
    

    layer-list 我也不懂,因为没用过这个鬼...

    3.在 \color{#ff0000}{style.xml}中,加上

    <style name="splash" parent="AppBaseTheme">
          <item name="android:windowBackground">@drawable/splash</item>
    </style>
    

    4.最后,在manifest中splash的activity标签配置主题

    <activity
           android:name="com.cs.SplashActivity"
           android:theme="@style/splash"
           android:label="@string/app_name">
           <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
           </intent-filter>
    </activity>
    

    即可

    相关文章

      网友评论

          本文标题:splash启动白屏

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