visual-studioxamarinxamarin.formsxamarin.androidxamarin-studio

How to remove space from the top of a splash screen in Xamarin.Forms?


I'm working on an application with Xamarin.Forms in Visual Studio 2019, I already have the splash screen but when I run it it doesn't cover the entire screen, it leaves a space where the notification bar should go, I already tried with the "NoTileBar" property and it did, but when opening it from the smartphone does not make the change. Could you help me change it?

Styles.xml

    <style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowBackground">@drawable/splash_screen</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowActionBar">true</item>
</style>

enter image description here


Solution

  • styles.xml

      <style name="MainTheme.Splash" parent="Theme.AppCompat.Light.NoActionBar">
       <item name="android:windowBackground">@drawable/splash_screen</item>
       <item name="android:windowNoTitle">true</item>
       <item name="android:windowFullscreen">true</item>
       <item name="android:windowContentOverlay">@null</item>
       <item name="android:windowActionBar">true</item>
      </style>
    

    Check your MainActivity Flags as shown below

    enter image description here

    Add SplshActivity class

      [Activity(Theme = "@style/MainTheme.Splash",
              MainLauncher = true,
              NoHistory = true)]
    public class SplashActivity : AppCompatActivity
    {
        // Launches the startup task
        protected override void OnResume()
        {
            base.OnResume();
            StartActivity(new Intent(Application.Context, typeof(MainActivity)));
        }
    }