For my app I am creating an Splash Screen using a drawable resource file consist of a layerlist having a colored background and a centered vector drawable for the logo.
splash_screen.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@color/grey_700" />
<item
android:drawable="@drawable/splash_foreground"
android:gravity="center" />
</layer-list>
style.xml
...
<style name="Theme.SplashScreen" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="android:statusBarColor">@color/grey_900</item>
<item name="android:windowBackground">@drawable/splash_screen</item>
</style>
...
AndroidManifest.xml
...
<activity
android:name=".MainActivity"
android:exported="true"
android:theme="@style/Theme.SplashScreen"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
...
splash_foreground.xml
Problem
the output should show splash_foreground
centered in the screen while the background color is cropped all over the screen but is showing a splash screen centered cropped.