首页 > 解决方案 > 颤动闪屏在物理设备上模糊

问题描述

我的目标是在应用程序初始化时显示启动画面。

所以我使用了这个包: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。

所以我的问题是:

  1. 我应该为我在里面绘制的画布指定宽度和高度吗?!

  2. 我应该为文本指定一个固定的字体大小吗...如果是这样...假设有两个文本...居中的一个...以及它下面的副标题。

我多次操纵字体大小,但每次生成的图像都很模糊......

任何帮助将非常感激。

编辑:

这是我绘制图像时来自 figma 的屏幕截图:

figma 截图

标签: flutterdart

解决方案


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" />

推荐阅读