<?xml version="1.0" encoding="utf-8"?> <!-- Modify this file to customize your launch splash screen --> <layer-listxmlns:android="http://schemas.android.com/apk/res/android"> <itemandroid:drawable="@android:color/white"/>
<!-- You can insert your own image assets here --> <item> <bitmap android:gravity="center" android:src="@drawable/splash_screen"/> </item> </layer-list>
values/styles.xml资源里定义一个启动主题,引用步骤2的背景:
1 2 3 4 5 6 7 8
<?xml version="1.0" encoding="utf-8"?> <resources> <stylename="LaunchTheme"parent="@android:style/Theme.Black.NoTitleBar"> <!-- Show a splash screen on the activity. Automatically removed when Flutter draws its first frame --> <itemname="android:windowBackground">@drawable/launch_background</item> </style> </resources>
<activity android:name=".MainActivity" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density" android:hardwareAccelerated="true" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:windowSoftInputMode="adjustResize"> <!-- This keeps the window background of the activity showing until Flutter renders its first frame. It can be removed if there is no splash screen (such as the default splash screen defined in @style/LaunchTheme). --> <meta-data android:name="io.flutter.app.android.SplashScreenUntilFirstFrame" android:value="true" /> <intent-filter> <actionandroid:name="android.intent.action.MAIN" /> <categoryandroid:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>