Search code examples
fluttersplash-screen

Flutter Spash Screen


android:src="@drawable/grouptop" /> How Can I Customize Image size of a splash screen image . I know by set its pixel size by image editing . but is there any way that I can customize the size (length , width) ?


Solution

  • make your launcher background like this in drawable folder

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    
        <item android:drawable="@android:color/white" />
    
        <item
            android:width="200dp"
            android:height="100dp"
            android:gravity="center"
            android:drawable="@drawable/splash">
        </item>
    </layer-list>
    

    use this style.xml

     <?xml version="1.0" encoding="utf-8"?>
        <resources>
            <style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
                <!-- Show a splash screen on the activity. Automatically removed when
                     Flutter draws its first frame -->
                <item name="android:windowBackground">@drawable/launch_background</item>
                <item name="android:windowDisablePreview">true</item>
    
            </style>
        </resources>
    

    defined in manifest file

    <activity
                android:name=".MainActivity"
                android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
                android:hardwareAccelerated="true"
                android:launchMode="singleTop"
                android:theme="@style/LaunchTheme"
                android:windowSoftInputMode="adjustResize">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>