如何为 flutter 制作 android 启动画面?
How do I make an android splash screen for flutter?
我看过很多文章和 youtube 视频并尝试了所有方法,但是我无法更改 android 初始屏幕颜色
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="@color/background" />
<!-- You can insert your own image assets here -->
<item>
<bitmap
android:gravity="center"
android:src="@drawable/launch_image" />
</item>
</layer-list>
values/colors.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="background">#2196F3</color>
</resources>
具有关键输出的生产版本:
使用此包创建本机启动画面非常简单。
https://pub.dev/packages/flutter_native_splash
将此包添加到您的 dev-dependencies
dev_dependencies:
flutter_native_splash: ^0.2.9
在您的 YAML 文件中添加以下代码。
flutter_native_splash:
color: "#42a5f5"
image: "assets/splash.png"
和运行命令
flutter pub run flutter_native_splash:create
就是这样,这个包会处理所有的过程。
FYI: This creates native splash screens for both Android and iOS, but
you can control it too. if you want to create only for Android, you
can set the iOS property to false. Documentation of the Package is
pretty clear.
我看过很多文章和 youtube 视频并尝试了所有方法,但是我无法更改 android 初始屏幕颜色
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="@color/background" />
<!-- You can insert your own image assets here -->
<item>
<bitmap
android:gravity="center"
android:src="@drawable/launch_image" />
</item>
</layer-list>
values/colors.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="background">#2196F3</color>
</resources>
具有关键输出的生产版本:
使用此包创建本机启动画面非常简单。
https://pub.dev/packages/flutter_native_splash
将此包添加到您的 dev-dependencies
dev_dependencies:
flutter_native_splash: ^0.2.9
在您的 YAML 文件中添加以下代码。
flutter_native_splash:
color: "#42a5f5"
image: "assets/splash.png"
和运行命令
flutter pub run flutter_native_splash:create
就是这样,这个包会处理所有的过程。
FYI: This creates native splash screens for both Android and iOS, but you can control it too. if you want to create only for Android, you can set the iOS property to false. Documentation of the Package is pretty clear.