Skip to content

Generated splash screen does not retain aspect ratio #5676

@hartez

Description

@hartez

Description

Splash screens on Android do not respect aspect ratio.

  • Android 21: there is just a total fill of the screen because the width/height concepts are only supported in Android 23+.
  • Android 33: (at least) the new splash system is designed for square images and as a result just does a fill. I did make the size shrink in Correctly size the Android 12 splash screen #9797, however, all the logic was just made to fix the way android just clips things.
  • Should we make sure the generated image is not huge

Workarounds

To fix Android 21, add a custom maui_splash_image.xml to drawable:

Platforms\Android\Resources\drawable\maui_splash.xml:

<?xml version="1.0" encoding="utf-8"?>
<!--This file was auto-generated by .NET MAUI.-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <bitmap android:gravity="center" android:src="@drawable/name_of_your_splash_image" android:mipMap="true" />
</layer-list>

To fix Android 23+, add a custom maui_splash_image.xml to drawable-v23:

Platforms\Android\Resources\drawable-v23\maui_splash.xml:

<?xml version="1.0" encoding="utf-8"?>
<!--This file was auto-generated by .NET MAUI.-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:width="108dp" android:height="108dp" android:gravity="center">
    <bitmap android:gravity="fill" android:src="@drawable/name_of_your_splash_image" android:mipMap="true" />
  </item>
</layer-list>

Make sure to use the name of your splash screen image in the place of name_of_your_splash_image.
Replace the width/height values if your image is not square.

Android 21 Android 33

Metadata

Metadata

Assignees

Labels

area-single-projectSplash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizerarea-toolingXAML & C# Hot Reload, XAML Editor, Live Visual Tree, Live Preview, Debuggingfixed-in-7.0.100fixed-in-7.0.101fixed-in-7.0.49Look for this fix in 7.0.49 GA!platform/androids/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions