【问题标题】:Prevent the launch screen from fading to black on Flutter / Android在 Flutter / Android 上防止启动屏幕变黑
【发布时间】:2021-01-05 19:18:44
【问题描述】:

我向我的 Flutter 应用 (Android) 添加了一个包含 PNG 图像的启动屏幕。在启动屏幕和正在显示的 Flutter 应用程序之间有一个非常明显的“变黑”。我不是说突然黑屏,而是启动屏幕真正淡出约 500 毫秒,然后出现 Flutter 应用程序。

我已经按照migration guide 使用了Android Embedding v2(但我之前没有使用启动画面,所以我不知道迁移是否是导致此问题的原因)。

这是我的launch_background.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:gravity="fill"
        android:drawable="@drawable/wood1" />

    <item>
        <bitmap
            android:gravity="center"
            android:src="@drawable/splash_foreground" />
    </item>
</layer-list>

这是我的normal_background.xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item
        android:gravity="fill"
        android:drawable="@drawable/wood1" />

</layer-list>

即使我只用白色替换 launch_background.xml 中的图像,它仍然会在渲染 Flutter 应用程序之前褪色为黑色。

在渲染应用程序之前,有什么想法会导致启动屏幕变黑吗?

【问题讨论】:

  • 当你发布应用程序时它就会消失。尝试使用真实设备以配置文件模式运行您的应用程序。然后看看这是否有什么不同。
  • 我也有这个问题,求消息
  • 它似乎在 Android 上的发布模式下消失了,但它在 iOS 上的调试/发布中都存在。

标签: android flutter splash-screen launch-screen


【解决方案1】:

也许你忘了在你的AndroidManifest 上添加这个,在 ...

之间
<meta-data
       android:name="io.flutter.embedding.android.SplashScreenDrawable"
   android:resource="@drawable/launch_background"
/>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-27
    • 1970-01-01
    • 1970-01-01
    • 2017-09-24
    相关资源
    最近更新 更多