Splash Screen In Xamarin.Forms Application For Android And UWP

A splash screen is a graphical control element consisting of a window containing an image, a logo, and the current version of the software. A splash screen usually appears while a game or program is being launched.

Reading this article, you will learn how to add Splash Screen in Xamarin.Forms application for Android and Universal Windows Platform with XAML and Visual C#, using Visual Studio 2017 RC.

The following important tools are required for developing UWP,

  1. Windows 10 (Recommended).
  2. Visual Studio 2017 RC Community/Enterprise/Professional Edition (It is a Free trial software available online).
  3. Using Visual studio 2017 Installer, enable the feature of Mobile development with .NET.

Now, we can discuss step by step app development.

Step 1

Open Visual Studio 2017 RC. Go to Start -> New Project-> Select Cross-Platform (under Visual C#->Cross Platform App-> Give suitable name for your app (XamFormSplash) -> OK.

 

Step 2

Select the Cross Platform template as Blank App, Set UI Technology as Forms, and Sharing as PCL.

 

Step 3

Now, creating project “XamFormSplash_Droid” …

 

Step 4

Afterwards, Visual Studio creates 4 projects and displays Getting Started.XamarinPage

 

Step 5

For adding splash screen feature in XamFormSplash_Droid project,  open MainActivity.cs and set the MainLauncher = false.
 
 

Add a new Activity file for Splash Screen demo, right click XamFormSplash_Droid project, and select Add-> NewItem.

Select ->Visual C#-> Activity-> Give the relevant activity name (Splash.cs).



Add the following code in Splash.cs for displaying splash screen image in Android project.
  1. [Activity(Theme = "@style/splashTheme", MainLauncher = true, NoHistory = true)]  
  2. protected override void OnCreate(Bundle savedInstanceState) {  
  3.     base.OnCreate(savedInstanceState);  
  4.     // Create your application here  
  5.     StartActivity(typeof(MainActivity));  
  6. }   
 

Add the splash screen image in XamFormSplash_Droid project Resources-> Drawable folder, and add the splash screen style to the Styles.xml in XamFormSplash_Droid project values folder.

  1. <style name="splashTheme" parent="android:Theme">  
  2.     <item name="android:windowBackground">@drawable/xamarin_logo</item><item name="android:windowNoTitle">true</item>  
  3. </style>   
 

Step 6

For adding splash screen feature in XamFormSplash_UWP project,  open Package.Appmanifest in XamFormSplash_UWP project -> select Visual Assets -> set the Source Splash screen image in Asset Generator, and click the "Generate" button.
 


Automatically, all the visual assets images are generated with suitable sizes.



 

Step 7 

Change the "Configuration Manager" settings. Go to Build -> Configuration Manager, and uncheck the "Build" and "Deploy" options to the iOS and check the "Droid" and "UWP".
 


Step 8

Deploy your app in Local Machine. The output of the XamFormSplash app is given below. 

 

After showing the splash screen.

 

Summary

Now, you have successfully tested Splash Screen in Xamarin.Forms application, using Visual C# and Xamarin in Visual Studio 2017 RC.

Up Next
    Ebook Download
    View all
    Learn
    View all