Reputation: 557
On Android versions older than Android 12 I am easily able to construct a splash screen with an image which is not cropped. For example like this on Android 11:
However, Android 12 introduced a new Splash Screen API and I can't figure out how to reproduce the splash screen above in Android 12. It seems that it is always cropped and turns out like this on Android 12:
This is my android/src/main/res/values/styles.xml
for older Android versions (e.g. Android 11):
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">@drawable/launch_background</item>
<item name="android:windowFullscreen">false</item>
</style>
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
This is my android/src/main/res/values-v31/styles.xml
for Android 12:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowSplashScreenAnimatedIcon">@drawable/launch_background</item>
<item name="android:windowFullscreen">false</item>
</style>
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
The only difference between the two styles.xml
is that I use android:windowSplashScreenAnimatedIcon
for Android 12 and android:windowBackground
for older Android versions as stated in the documentation for the new splash screen API (https://developer.android.com/guide/topics/ui/splash-screen).
Both styles.xml
use @drawable/launch_background
which is defined in android/src/main/res/drawable/launch_background.xml
as follows:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<bitmap android:gravity="fill" android:src="@drawable/background"/>
</item>
<item>
<bitmap android:gravity="center" android:src="@drawable/splash"/>
</item>
</layer-list>
@drawable/background
is just a .png
with a single white pixel (1x1) and splash.png
(1280x721) is the actual image I want to show in the splash screen which should not be cropped. I uploaded both files here: https://i.sstatic.net/x3QU9.jpg
With the new Android 12 Splash Screen API, is it even possible to get a splash screen which is identical to the result I got with Android 11 (no cropping of the background image)? If yes, how is that possible?
Upvotes: 5
Views: 3453
Reputation: 1636
No, it's not possible. The goal of the new splash screen is to unify the Splash Screen UX and the cropping is part of the design.
Upvotes: 3