美文网首页
Flutter解决启动页面白屏黑屏问题

Flutter解决启动页面白屏黑屏问题

作者: Jam_Chan | 来源:发表于2020-07-15 17:09 被阅读0次

1、在配置文件下的Activity之间加入:

<activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- 去除启动页的白屏 -->
            <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" />

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

2、启动页面背景在drawable目录下的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/white" />

    <!-- You can insert your own image assets here -->
    <!-- 设置启动页背景 -->
    <item>
        <bitmap
            android:gravity="center"
            android:src="@drawable/splash" />
    </item>
</layer-list>

相关文章

网友评论

      本文标题:Flutter解决启动页面白屏黑屏问题

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