解决Flutter安卓端启动白屏的问题

修改主题:
styles.xml

<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>

    <item name="android:statusBarColor">@android:color/white</item>
    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowIsTranslucent">false</item>
    <item name="android:windowNoTitle">true</item>
</style>

AndroidManifest.xml

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

<meta-data
    android:name="io.flutter.embedding.android.SplashScreenDrawable"
    android:resource="@drawable/launch_background"/>

launch_background.xml(drawable和drawable-v21的都需要修改)

<?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="@mipmap/welcome_bg" />

    <!-- You can insert your own image assets here -->
    <!--<item>
        <bitmap
            android:gravity="center"
            android:src="@mipmap/welcome_logo" />
    </item>

    <item android:top="200dp">
        <bitmap
            android:gravity="center"
            android:src="@mipmap/welcome_coming" />
    </item>-->
</layer-list>

welcome_bg.pgn放在mipmap-xxhdpi目录下

Guess you like

Origin blog.csdn.net/ithouse/article/details/116856331