Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flutter splash screen jump on android

I wanted to implement my splash screen in flutter. as mentioned here, I created my splashScreen's theme inside styles.xml file and put below code:

<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
    <item name="android:windowBackground">@drawable/launch_background</item>
</style>

and in launch_background file I put these code:

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

i launched the app, after loading background I faced a 'jump' of a centered logo image. how can I fix this jump?

like image 949
ali samawi Avatar asked Dec 08 '22 10:12

ali samawi


1 Answers

For anybody having this issue still and the solution(s) over at GitHub don't seem to be working:

In your main AndroidManifest.xml file, you probably have these lines given as a solution from the aforementioned GitHub answer:

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

You may have placed those lines at the bottom alongside the "flutterEmbedding" meta-data tag. If you did, put them within the <activity> tag instead as shown in this example:

<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>
like image 161
J. Saw Avatar answered Jan 08 '23 21:01

J. Saw