1

I wanted to use a SplashScreen in my .NET MAUI App which is showing a JPG FullScreen and also just thinking of showing also Version Information on the same page.

When I double click on my Project-File, I can see an ItemGroup in which I set my jpg

<ItemGroup>
...
    <MauiSplashScreen Include="Resources\Splash\mySplash.jpg" BaseSize="128,128" Color="#FFFFFF" Aspect="AspectFill" />
...
</ItemGroup>

Okay, I've just set a small BaseSize here, but AspectFill did not work at all and also there is no possibility to set an additional Label do have Version information below.

The Version information for now is not a must, but would be nice. But, a must have for me is that my JPG is shown full screen. Currently, it is shown within a circle.

I tried with my own ContentPage and added it to App.xaml.cs Unfortunately, it wasn't shown as SplashScreen and just could see the typical Blue Screen with the ".NET"-Logo when my App was started in Pixel 5 - API 33 (Android 13.0 - API 33)-Emulator

public App()
{
    InitializeComponent();

    MainPage = new MySpalshScreen();
}

Is there a way to show my own ContentPage and after about 3 seconds move on to my normal Main-Page?


Added Screenshot to Comment

This is how it is displayed when I start my App:

  • First of all, I get the Standard-SplashScreen-Background where we would normally see the .NET-Logo
  • Then my own SplashScreen-ContentPage with the Dotnet_Bot.svg is loaded
  • First of all it shows the standard blue background where we would normally see the .NET-Logo as Splash-Screen. By double-clicking on my project, I already commented out <!--<MauiSplashScreen Include="Resources\Splash\dotnet_bot.svg" BaseSize="128,128" Color="#FFFFFF" Aspect="AspectFill" /> -->

Splash_Behavior

OXO
  • 391
  • 1
  • 8

1 Answers1

1

it still shows the Background-Color of the standard .NET-SplashScreen

with the following settings I can show the exact appearance of my splash screen:

<MauiSplashScreen Include="Resources\Splash\splashscreen.jpg" Color="#999" BaseSize="240,240"/>

Example1

by changing the Color to #000 in my case I get a seamless splash screen

Example

You can have a look at the official documentation for android splash screen dimentions to understand why its masked as a circle.

Now if you get a .png (or better .svg) with transparent background, you can have your logo without the circle mask.

<MauiSplashScreen Include="Resources\Splash\splashscreen.png" Color="#999" BaseSize="240,240"/>

Example3

Note that I had to reset the project in several ways until it really swapped the image to the png, some of the things I tried were Cleaning and rebuilding the project, deleting the obj folder in the file explorer and I tried removing Color property MauiSplashScreen and then I saw a difference, It had the primary colour of the theme on the background and the colour I just deleted in the image background, I gave back the Color property and it worked.


To delay the change of page you could just await a delay such as

await Task.Delay(ms);

then invoke the main page

    public partial class App : Application
    {
        public App()
        {
            InitializeComponent();

            MainPage = new MySpalshScreen();

            _ = EndSplash();
        }

        async Task EndSplash()
        {
            //delay 3 seconds
            await Task.Delay(3000);
            MainThread.BeginInvokeOnMainThread(() =>
            {
                MainPage = new AppShell();
            });
        }
    }

Example

Barreto
  • 374
  • 2
  • 14
  • Thanks a lot for your response and explanation how it would work. I will mark this as Answer afterwards. Just a little problem I am still facing, when I start my App. First of all it shows the standard blue background where we would normally see the .NET-Logo as Splash-Screen. By double-clicking on my project, I already commented out – OXO Mar 25 '23 at 12:15
  • you should add this notes to the question itself so everybody can see, maybe someone knows better and can provide a better answer. but if you like you can upvote regardless. I will update my answer if I have any relevant information to add – Barreto Mar 25 '23 at 12:38
  • btw I gave [this](https://learn.microsoft.com/en-us/dotnet/maui/user-interface/images/splashscreen?view=net-maui-7.0&tabs=android) a read and I need to update my emulator because my android API is older than 31, and since you mention you are using 33. I cant reproduce the example. but I noticed something, you are trying to use a `.jpeg` on the splash screen, the documentation says `"By default, bitmap (non-vector) image formats are not automatically resized by .NET MAUI."` – Barreto Mar 25 '23 at 12:55
  • meaning, could you try `Resize="true"` on the splash screen? – Barreto Mar 25 '23 at 12:58
  • The Resize-Problem you mentioned is also one of mine with JPG and also converted SVG. It does look like bad resolution. But, my real issue is, that at least in my emulator (don’t know about a real device), it still shows the Background-Color of the standard .NET-SplashScreen and on top of that my 3second own splash screen. Usually, it should have replaced the standard SplashScreen. Is there a way to achieve this? – OXO Mar 25 '23 at 14:37
  • Hhm that is strange when I look at your black version above, since my Image is basically very large: 3012x3844. But actually I did not want to set a size in my XAML as there are different devices with different resolutions. Even when I can get my png as transparent svg it is strange that I can’t see it in full resolution. Is it really that I have to set a size there? – OXO Mar 25 '23 at 19:06
  • I dont understand. is this related to the question? – Barreto Mar 25 '23 at 19:35
  • It was related to your enhancement of your answer above with the screenshot and the image with the „G“ and comment about transparency – OXO Mar 25 '23 at 21:41
  • The black version is not the one with transparency. And you are talking about size, you mean `BaseSize`? – Barreto Mar 26 '23 at 04:57
  • Maybe it was misleading: When my App starts, I don’t want to see the blueisch background and the .NET-Logo, but my own SplashScreen. Since I deactivated the SplashScreen in App-csproj, I was wondering that I still see the blue Background and when this disappears, I see my own SplashScreen for additional 3 seconds, which is more time than usual for the Splash. Additionally, my own SplashScreen is a ContentPage with sharp photo in the resolution I mentioned, but it does not appear with sharpness and doesn’t look as professional then. Is BaseSize something that is ignored when possible by dif OS? – OXO Mar 26 '23 at 05:50
  • So you have the default splash that is required to load the app then the custom splash screen with the delay that enables you to display the version of the app. Now you are wondering about the resolution.. this is a bunch of topics and its getting messy. You question was closed possibly for the wrong motives, you should do a new question with a single focus, such as, why my image loses resolution, if you cant find info. – Barreto Mar 26 '23 at 11:31