解决 优化 app 启动页 白屏 、 黑屏问题

1、需求:Android app  启动时 总是黑屏或者白屏 1秒钟   产品 要去改进 体验、

于是 再 启动页 添加了 新的style 配置 成功解决 问题

代码如下:manifest 中app  启动页 :

   <activity android:name=".WelcomeActivity"
            android:theme="@style/welcome">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

 划重点:

 android:theme="@style/welcome"

style 文件中添加:

  <style name="welcome" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="android:windowBackground">@drawable/splash_drawable</item>
        <!--        <item name="android:windowTranslucentStatus">true</item>-->
        <item name="android:windowFullscreen">true</item>
    </style>

splash_drawable 文件内容:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@android:color/white" />
    <item>
        <bitmap
            android:gravity="bottom"
            android:scaleType="centerCrop"
            android:src="@drawable/splash"
            android:tileMode="disabled" />
    </item>
</layer-list>

需要一张 初始化的整体图片 splash 放在drawable 文件夹下。

 如果解决了你的问题 麻烦点个赞谢谢

发布了16 篇原创文章 · 获赞 5 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/u013783167/article/details/105779110