Flutter android上的flatter闪屏跳跃

Flutter android上的flatter闪屏跳跃,flutter,flutter-layout,Flutter,Flutter Layout,我想在flutter中实现我的启动屏幕。 如前所述,我在styles.xml文件中创建了splashScreen的主题,并将其放在下面的代码中: <style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar"> <item name="android:windowBackground">@drawable/launch_background</item> </sty

我想在flutter中实现我的启动屏幕。 如前所述,我在
styles.xml
文件中创建了splashScreen的主题,并将其放在下面的代码中:

<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
    <item name="android:windowBackground">@drawable/launch_background</item>
</style>
我启动了这个应用程序,在加载背景后,我遇到了一个中心标志图像的“跳跃”。 如何修复此跳转?

找到此跳转后,我通过将下面的代码放入
LaunchTheme
(位于
styles.xml
文件中)来修复问题:


@可绘制/发布背景
假的

对于仍存在此问题且解决方案似乎不起作用的任何人:

在您的主AndroidManifest.xml文件中,您可能有以下几行代码作为上述GitHub答案的解决方案:

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

您可能已经将这些行放置在“嵌入”元数据标记旁边的底部。如果是,请将它们放在
标记中,如本例所示:

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

如果还有人对此有问题:
style.xml中删除这一行解决问题:

true

路径:
android/app/src/main/res/values/styles.xml

我通过添加以下行解决了这个问题:

<item name="android:windowDrawsSystemBarBackgrounds">true</item>
true
到LaunchTheme样式下的my styles.xml,因此my styles.xml文件现在是:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
        <item name="android:windowBackground">@drawable/launch_background</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:windowNoTitle">true</item>
    </style>
</resources>

@可绘制/发布背景
真的
真的

这只是一个解决办法,在启动屏幕和等待屏幕之间仍然有一个空白屏幕:

您的styles.xml文件应如下所示:

@可绘制/发布背景 真的 如果他们是另一个更好的解决方案,将更新。

对我来说,第3点解决了我的问题:

只需添加
windowDisablePreview

<style name="LaunchTheme" parent="@style/Theme.AppCompat.NoActionBar">
    <!-- Show a splash screen on the activity. Automatically removed when
         Flutter draws its first frame -->
    <item name="android:windowBackground">@drawable/launch_background</item>
    <!-- Prevent splash screen to jump when transitioning from LaunchTheme to NormalTheme.
         See https://github.com/flutter/flutter/issues/47634#issuecomment-588233633-->
    <item name="android:windowDisablePreview">true</item>
</style>

@可绘制/发布背景
真的

为我修复了错误
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
        <item name="android:windowBackground">@drawable/launch_background</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:windowNoTitle">true</item>
    </style>
</resources>
<style name="LaunchTheme" parent="@style/Theme.AppCompat.NoActionBar">
    <!-- Show a splash screen on the activity. Automatically removed when
         Flutter draws its first frame -->
    <item name="android:windowBackground">@drawable/launch_background</item>
    <!-- Prevent splash screen to jump when transitioning from LaunchTheme to NormalTheme.
         See https://github.com/flutter/flutter/issues/47634#issuecomment-588233633-->
    <item name="android:windowDisablePreview">true</item>
</style>