003-Flutter的App闪屏页设置
作者:互联网
在Flutter项目中,好像之前的版本设置闪屏页都比较复杂,但是现在比较简单了,可以在 android 项目的清单文件中进行如下设置:
<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">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<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>
从上面的介绍来可以看出,在 SplashScreenDrawable 的所属 meta-data 中可以对闪屏页的图片进行设置,修改 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:scaleType="center"
android:src="@mipmap/ic_launcher" />
</item>
<!-- 底部-->
<item android:bottom="65dp">
<bitmap
android:gravity="bottom|center_horizontal"
android:scaleType="center"
android:src="@mipmap/screen_txt"
/>
</item>
</layer-list>
注意:这里的 launch_background.xml 修改涉及到两处,一处是在drawable目录下 ,一处是在drawable-v21目录下,否则不出效果。
修改完成之后,启动可以看出效果如下:
标签:xml,background,launch,App,003,闪屏,设置,Flutter 来源: https://blog.csdn.net/happiness365/article/details/116275042