我想在 flutter 中实现我的启动画面。
如前所述here ,我在 styles.xml
中创建了我的 splashScreen 主题文件并输入以下代码:
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
在
launch_background
文件我把这些代码:<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/black" />
<item>
<bitmap
android:gravity="center"
android:src="@drawable/ic_splash" />
</item>
我启动了应用程序,在加载背景后,我遇到了居中 Logo 图像的“跳跃”。
我该如何解决这个跳跃?
最佳答案
对于仍然存在此问题的任何人以及 GitHub 上的解决方案似乎没有工作:
在您的主要 AndroidManifest.xml 文件中,您可能从上述 GitHub 答案中给出了这些行作为解决方案:
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background" />
您可能已将这些行放在“flutterEmbedding”元数据标签旁边的底部。如果你这样做了,请将它们放在
<activity>
中标记代替,如本例所示:<application
android:name="io.flutter.app.FlutterApplication"
android:label="flutter_launch_new"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- HERE -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<!-- NOT HERE -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
关于在android上 flutter 闪屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61255630/