Splash screen not displaying full screen in .NET Maui when Android 12 and higher versions. The splash screen contains a logo as usual and the few lines of text at the bottom. The issue is images and text look very small and are not displaying in full screen compared to other versions.It displays the full screen with the below version, like, for example, Android 9. I have tried splash screen as a content page, but it gets a delay in performance compared to previous versions. so please help to resolve the issue.sample screenshot attached
0
From document Add a splash screen to a .NET MAUI app project,we know that
On Android 12+ (API 31+), the splash screen shows an icon that’s
centred on screen.
On Android 12+ (API 31+),it’s impossible to make image to full screen in splash screen. It is only possible to customize it: icon, window background, exit animation. Please check document: Splash screens on developer.android.com.
However, there is a workaround to make the splash screen to transparent, and then you can create a splashScreen with ContentPage, add images in the ContentPage.
Step 1. Create styles.xml
at Platforms/Android/Resources/values
folder, and add the following code to customize style. And make sure the build action
of styles.xml
is AndroidResource
.
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="MyTheme.Splash" parent ="MainTheme">
<item name="android:windowIsTranslucent">true</item>
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowSplashScreenAnimatedIcon">@android:color/transparent</item>
<item name="android:windowSplashScreenAnimationDuration">0</item>
</style>
</resources>
Step2. Open the MainActivity.cs
, change the theme to Theme = "@style/MyTheme.Splash"
.
[Activity(Theme = "@style/MyTheme.Splash", ...)]
public class MainActivity : MauiAppCompatActivity
{
}
Step3. please create a Contentpage called SplashScreen
and add your image to it. And open the Mainpage after several seconds by Task.Delay()
and Application.Current.MainPage = new MainPage ();
.
Just like the following code.
protected override async void OnAppearing()
{
base.OnAppearing();
await Task.Delay(1000).ContinueWith(t => {
MainThread.InvokeOnMainThreadAsync(() => {
Application.Current.MainPage = new MainPage ();
});
});
}
Step4. open the App.xaml.cs
, change the MainPage to the SplashScreen.
public partial class App : Application
{
public App()
{
InitializeComponent();
MainPage = new SplashScreen();
}
}
4