原来使用原生开发webview外壳,APK有8Mb启动是毫秒级的,使用Flutter开发类似功能的,APK至少都18Mb起,启动会有个黑屏(有的显示白屏),现在怎样使用图片代替黑屏呢?以下几步,如果对应的文件没有就添加

1、styles.xml文件

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
        <!-- Show a splash screen on the activity. Automatically removed when
             Flutter draws its first frame -->
        <item name="android:windowBackground">@drawable/launch_background</item>
    </style>
</resources>

2、launch_background.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@android:color/black"/>

    <!-- You can insert your own image assets here  home6为图片名称-->
    <item>
        <bitmap
                android:src="@mipmap/home6"/>
    </item>
</layer-list>

3、AndroidManifest.xml 添加、调整内容

 

android:theme="@style/LaunchTheme"


<meta-data
                android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
                android:value="true" />

 

Logo

开源鸿蒙跨平台开发社区汇聚开发者与厂商,共建“一次开发,多端部署”的开源生态,致力于降低跨端开发门槛,推动万物智联创新。

更多推荐