【问题标题】:How to make the splash screen background transparent in flutter (for both Android and IOS)?如何使闪屏背景在颤动中透明(适用于Android和IOS)?
【发布时间】:2020-02-21 06:59:03
【问题描述】:

我想让初始屏幕背景透明,以便在应用启动时仅在屏幕上显示一个图标。

到目前为止,我在 launch_background.xml for Android 中所做的工作:

<?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/transparent" />
     <item>
        <bitmap
            android:src="@drawable/index"
            android:gravity="center"
            />
    </item>
</layer-list>

但我得到的是黑色背景,例如:

图像

我想要的是这样的:

The image

如何正确解决这个问题?谢谢!

顺便说一句:IOS 呢?

【问题讨论】:

  • 你想通过透明度展示什么?手机背景?这不是它的工作原理。该应用程序有自己的窗口。黑色背景是应用程序“背后”的内容。
  • @Paulw11 嗨,我想要的是这样的:i.stack.imgur.com/shpHW.png
  • 你在 iOS 上绝对做不到。

标签: android ios flutter


【解决方案1】:

我下载了一张透明图片,在flutter中用它作为我在flutter_native_splash下的背景图片。效果很好。

flutter_native_splash:
  background_image: "lib/assets/transpbackground.png"
  image: lib/assets/translogo.png
  android_gravity: center
  fullscreen: true
  ios_content_mode: center
  ..android: true
  ..ios: true

【讨论】:

  • 代码放在pubspec.yaml文件中。
猜你喜欢
  • 2020-01-22
  • 2021-12-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-08-16
  • 1970-01-01
  • 2021-01-07
  • 1970-01-01
相关资源
最近更新 更多