简体   繁体   English

flutter 中,如何去掉原生启动画面和主画面之间的默认淡入淡出过渡? (仅使用本机启动画面)

[英]How to remove the default fade transition between the native splash screen and the home screen in flutter? (Using native splash screen only)

I have a native splash screen in flutter, but when the splash screen ends, it has a fade animation to my app home screen.我在 flutter 中有一个本机启动画面,但是当启动画面结束时,它会淡出 animation 到我的应用程序主屏幕。 I need to remove that, and still use the native splash.我需要删除它,并且仍然使用本机启动画面。 How can I do that?我怎样才能做到这一点?

Here is what I found:这是我发现的:

  • Open your Android project inside your Flutter project在 Flutter 项目中打开 Android 项目
  • In you Android project, go to app/src/main/AndroidManifest.xml在你的 Android 项目中,go 到app/src/main/AndroidManifest.xml
  • in that AndroidManifest.xml file, you should find one activity block在那个AndroidManifest.xml文件中,你应该找到一个activity
  • in that block, comment or remove the two meta-data blocks, especially this one:在该块中,注释或删除两个meta-data块,尤其是这个:
    <meta-data
        android:name="io.flutter.embedding.android.SplashScreenDrawable"
        android:resource="@drawable/launch-background" />

Not only the splash screen will still works, because you have android:theme=@style/LaunchTheme as attribute of the MainActivity , but il will also remove the glitch that you may have on your splash screen that shifts a little bit your logo (if you have one in your splash screen of course).不仅启动画面仍然有效,因为您有android:theme=@style/LaunchTheme作为MainActivity的属性,而且 il 还将消除启动画面上可能出现的小故障,该小故障会稍微移动您的徽标(如果当然,您的启动画面中有一个)。

That solution works (at least for me) if you have a basic splash screen.如果您有一个基本的初始屏幕,该解决方案(至少对我而言)有效。 I haven't tested that with a more advanced custom animated splash screen for example, so it might not be the perfect solution for everyone.例如,我没有使用更高级的自定义动画启动画面对其进行测试,因此它可能不是适合所有人的完美解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM