Xamarin Guide 6: Add Splash Screen, Name and Version

Scope

This Xamarin Workshop Guide was created for the The Portuguese National Meeting of IT Students (ENEI) by Sara Silva and the original content is available here. To extend it to the global community, it was published in a new project called Xam Community Workshop and the main goal is for any developer, or user group to customize it to their events.

Before reading this article you must read:

Guide 6. Add splash screen, name and version

In this step you will learn how to create the splash screen for all platforms and how to define the name and version of the application.

Define the splash screen

The splash screen in mobile applications is the first screen that the user will see, in some applications it is used to load the initial data. It is defined in various ways for each platform and for each one you will learn how it works.

  • In ENEI.SessionsApps.iOS

In iOS and iPad applications it is possible to define launch images as a splash screen in the Info.plist. It is described in the following figures:



Figure 6-1: Defining Launch Images using Visual Studio



Figure 6-2: Defining Launch images in Xamarin Studio

  • In ENEI.SessionsApps.Android

By default, in Android applications, there is no concept of a splash screen. To solve it, is possible to create an Activity that will be a splash screen page.

In the ENEI.SessionsApp create the SplashScreen class, as in the following:

  1. [Activity(Label = "1010 ENEI", MainLauncher = true, NoHistory = true, Theme = "@style/Theme.Splash", ConfigurationChanges = ConfigChanges.ScreenSize, ScreenOrientation = ScreenOrientation.Portrait)]  
  2. public class SplashScreen : Activity  
  3. {  
  4.      protected override void OnCreate(Bundle bundle)  
  5.      {  
  6.          base.OnCreate(bundle);  
  7.   
  8.          var intent = new Intent(thistypeof(MainActivity));  
  9.          StartActivity(intent);  
  10.          Finish();  
  11.      }  
  12. }  
In the Resources\Values folder create an XML file called Style, as in the following: 
  1. <?xml version="1.0" encoding="utf-8" ?>  
  2. <resources>  
  3.   <style name="Theme.Splash" parent="android:Theme">  
  4.     <item name="android:windowBackground">@drawable/splash</item>  
  5.     <item name="android:windowNoTitle">true</item>  
  6.   </style>  
  7.   <style name="Theme.ENEI" parent="android:Theme.Holo">  
  8.   </style>  
  9. </resources>  
Then change the MainActivity to: 
  1. [Activity(Label = "1010 ENEI", Theme = "@style/Theme.ENEI", ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]  
  2.     
  3. public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity  
  4. {  
  5.       protected override void OnCreate(Bundle bundle)  
  6.       {  
  7.            base.OnCreate(bundle);  
  8.            global::Xamarin.Forms.Forms.Init(this, bundle);  
  9.            ActionBar.SetIcon(Resource.Drawable.ic_action_users);  
  10.            LoadApplication(new App());  
  11.       }  
  12. }  
If you run the Android application you will get the “splash screen” defined, similar to the other platforms.

See more about it in this article Creating a Splash Screen.

  • In ENEI.SessionsApps.WinPhone

Windows Phone applications support splash screens by default, this way it only required a nice image that will be shown to the user.

Figure 6-3: The SplashScreenImage

Define the name and the version for each platform

To define the name and the version for each platform you will need:

  • In ENEI.SessionsApps.iOS

Open the Info.plist or the project's properties as described in Figure 6-4 and Figure 6-5.

Figure 6-4: Defining Name and Version using Xamarin Studio (Info.plist)



Figure 6-5: Defining Name and Version using Visual Studio (project's properties)

  • In ENEI.SessionsApp.Android

Open the project's properties as described in Figure 6-6 and Figure 6-7.



Figure 6-6: Defining Name and Version using Xamarin Studio (project's properties)



Figure 6-7: Defining Name and Version using Visual Studio (project's properties)

  • In ENEI.SessionsApps.WinPhone

Open the manifest file as describe in the Figure 6-8 and Figure 6-9.



Figure 6-8: Defining Name in the manifest file



Figure 6-9: Defining Version in the manifest file

Up Next
    Ebook Download
    View all
    Learn
    View all