Search code examples
c#androidsplash-screenuno-platform

Uno Platform Android Splash screen does fully go away


I have a project using the UNO platform. The iOS version of the splashscreen works perfectly. The android version is displayed and seems to go away.

However, it still shows up in the background behind the elements on the page unless I have a border or a webview on the page.

I implemented the splashscreen doing the following:

Styles.xml

<!-- Splash screen -->
<item name="android:windowBackground">@drawable/splash</item>

Splash.xml in Resources/drawble:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
  <item>
    <!-- background color -->
    <color android:color="#dedcdc"/>
  </item>
  <item>
    <!-- splash image -->
    <bitmap
        android:src="@drawable/splashscreen"
        android:tileMode="disabled"
        android:gravity="center" />
  </item>
</layer-list>

I then put an image in the Splashscreen.scale-200.png. The splashscreen does appear and then appears to go away once the app loads, so I am really confused as to why it never fully goes away.

I have noticed that any elements like the navigation menu and buttons etc do appear over the splashscreen and hide the portion of it. I am using the latest Uno with the prelease updated today. I am testing on the simulator and on a Pixel 3a.


Solution

  • This is the standard way to show a splash screen on Android because it loads almost instantly, ensuring your users aren't staring at a blank screen - in other words, what a splash screen is supposed to do.

    Note however that you're really setting the windowBackground property, so it's expected that the splash screen doesn't 'go away' - it's always going to be there behind the rest of your content. Normally it's never subsequently seen because it's covered by the content. To make sure this is the case, the root of your UI normally has an opaque background that takes up the whole screen. Eg, for a 'Hello World' app from the default Uno template:

        <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
            <TextBlock Text="Hello, world!" Margin="20" FontSize="30" />
        </Grid>
    

    In this case the root Grid will completely obscure the native windowBackground.

    If you're seeing the splash screen even after your content has loaded, it means it has a non-opaque background or its not taking up the entire screen. Try setting the Background property of the root view in your UI as above.