Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add better support for Android 12+ Splash Screen APIs #9794

Closed
mattleibow opened this issue Aug 30, 2022 · 5 comments · Fixed by #9797
Closed

Add better support for Android 12+ Splash Screen APIs #9794

mattleibow opened this issue Aug 30, 2022 · 5 comments · Fixed by #9797
Labels
area-single-project Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer fixed-in-6.0.540 Look for this fix in 6.0.540 SR5! fixed-in-7.0.0-rc.1.6683 platform/android 🤖
Milestone

Comments

@mattleibow
Copy link
Member

mattleibow commented Aug 30, 2022

Description

As part of Android's ongoing improvements and changes to splash screens, Android 12+ has additional image requirements:

The first issue was that images were not showing at all because of new things, but that was fixed in #8394

However, those changes also missed the image size requirements. As of now, the image is still the large sizes from the source image which results in it being clipped. This issue is to track any work to automatically fit the screen.

Workaround

Add a file into your .NET MAUI app with this exact name:

Platforms\Android\Resources\drawable\maui_splash.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:opacity="opaque">
	<item android:drawable="@color/maui_splash_color" />
	<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

Related:

@mattleibow mattleibow added this to the .NET 7 Planning milestone Aug 30, 2022
@mattleibow mattleibow added area-single-project Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer platform/android 🤖 labels Aug 30, 2022
@mattleibow mattleibow changed the title Add support for Android 12+ Splash Screen APIs Add better support for Android 12+ Splash Screen APIs Aug 30, 2022
@mattleibow mattleibow modified the milestones: .NET 7 Planning, 6.0-sr5 Aug 31, 2022
@developer9969
Copy link

Great news!!!. Will this workaround work for xamarin forms too?

@mattleibow
Copy link
Member Author

Great news!!!. Will this workaround work for xamarin forms too?

I don't think forms has resizetizer as part of it... However, you can use the same xml and add it to your own project - whatever you called your drawable files. The trick is really to set thesplash size somewhere to a small size and put your image in there. But, just for Android 12+

@speschka
Copy link

speschka commented Sep 7, 2022

I've tried the above work around multiple times in multiple ways and it will not compile. First it looks for your splash file in the same directory as the XML file. When I copy the file in there it gives me a System.IO.Exception error - process cannot access the file because it's being used by another process. If I try and change the splash image name and update the XML file to the new name, then I get a file can't be found error, and failed linking file resources error. Maybe this just needs more instructions, or maybe it's not working with the GA of MAUI (6.0.400).

@WebGoose
Copy link

Workaround is not working for me either unfortunately. The file is called splashscreen.svg and I've tried @drawable/splashscreen, @drawable/splashscreen.svg and neither work.

@ghost
Copy link

ghost commented Sep 16, 2022

Hello lovely human, thank you for your comment on this issue. Because this issue has been closed for a period of time, please strongly consider opening a new issue linking to this issue instead to ensure better visibility of your comment. Thank you!

@ghost ghost locked as resolved and limited conversation to collaborators Oct 16, 2022
@samhouts samhouts added the fixed-in-6.0.540 Look for this fix in 6.0.540 SR5! label Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-single-project Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer fixed-in-6.0.540 Look for this fix in 6.0.540 SR5! fixed-in-7.0.0-rc.1.6683 platform/android 🤖
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants