Flutter啓動黑屏處理

       原來使用原生開發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" />

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章