我的目标是在应用初始化时显示启动画面。
所以我使用了这个包:flutter_native_splash: 0.1.9
根据 pub.dev 上的 flutter_native_splash 文档,我根据需要创建了这个文件:
flutter_native_splash:
image: assets/images/splash.png
color: "#ffffff"
fill: true
# android_disable_fullscreen: true
在终端中我运行了这个命令:
flutter pub run flutter_native_splash:create
该包为我生成了 drawable-hdpi、drawable-mdpi、drawable-xdpi、drawable-xxdpi、drawable-xxxhdpi 中的图像
现在我可以成功使用这个启动画面,但问题是当我测试时,生成的图像在物理设备上非常模糊...
是否有任何关于如何从一开始就绘制此图像的指南?
它只是一个带有居中文本的简单黑色图像......让我们说例如“启动画面”
我使用 figma 进行绘图并将文件导出为 SVG。
所以我的问题是:
我应该为我在里面绘制的画布指定宽度和高度吗?!
我应该为文本指定一个固定的字体大小吗...如果是这样...假设有两个文本...居中的一个...下面有一个副标题。
我多次操作字体大小,但每次生成的图像都很模糊...
任何帮助将不胜感激。
编辑:
这是我在绘制图像时从 figma 中截取的截图:
答案 0 :(得分:0)
1.) 制作大小为 1080*1920 的启动画面背景图片,将其添加到 drawable 文件夹(android/app/src/main/res/drawable)中。
2.) 将下面的代码添加到你的android的styles.xml中
<resources>
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">@drawable/splash</item>
</style>
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">@drawable/splash</item>
</style>
</resources>
3.) 在 AndroidManifest.xml 标签内添加以下代码
android:name="io.flutter.app.FlutterApplication"
4.) 在您的第一个活动中添加元数据。
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" />