Download Code

Xamarin Splash Screen Example Android

In this tutorial you will learn how to create xamarin splash screen example android using Thread in android application.More practical detail you visit this tutorial.First i’ll tell you about splash screen then we will go with thread to run it for some time and then start home screen.

Xamarin Splash Screen

It’s an activity which set for some time and after some time it redirects to home/main activity.

Now let’s talk about splash screen sizes.We have to develop an application that support maximum devices.

LDPI

  • Portrait: 200×320 px
  • Landscape: 320×200 px

MDPI

  • Portrait: 320×480 px
  • Landscape: 480×320 px

HDPI

  • Portrait: 480×800 px
  • Landscape: 800×480 px

XHDPI

  • Portrait: 720×1280 px
  • Landscape: 1280×720 px

XXHDPI

  • Portrait: 960×1600 px
  • Landscape: 1600×960 px

XXXHDPI

  • Portrait: 1280×1920 px
  • Landscape: 1920×1280 px

These are screen densities to support our application.Now go ahead and create images in Photoshop just like me i have taken an example of this application.

Xamarin Splash Screen,Xamarin Splash Screen example,xamarin splash screen example android,splash screen example android,

Ok i am done with images.Now go ahead and create android application project.

Next drop splash screen images in their respective directory just like this.Remember one thing that every image should have same name.

Xamarin Splash Screen,Xamarin Splash Screen example,xamarin splash screen example android,splash screen example android,

Then go to Main.axml file and drag,drop image view and set image src to splash.

Xamarin Splash Screen,Xamarin Splash Screen example,xamarin splash screen example android,splash screen example android,

Now go to MainActivity.cs class.Create thread variable and set window/layout which display in application to full screen.Create new activity and layout which we will call home screen/activity.

Put exception handling thread and start Thread.

Home.axml

Xamarin Splash Screen,Xamarin Splash Screen example,xamarin splash screen example android,splash screen example android,

Home.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
namespace XamarinSplashScreen
{
	[Activity(Label = "Home")]
	public class Home : Activity
	{
		protected override void OnCreate(Bundle savedInstanceState)
		{
			base.OnCreate(savedInstanceState);
			SetContentView(Resource.Layout.Home);
		}
	}
}

MainActivity.cs

using Android.App;
using Android.Widget;
using Android.OS;
using System.Threading;
using System;
using Android.Content;
using Android.Views;

namespace XamarinSplashScreen
{
	[Activity(Label = "XamarinSplashScreen", MainLauncher = true, Icon = "@mipmap/icon" , Theme = "@android:style/Theme.Black.NoTitleBar.Fullscreen")]
	public class MainActivity : Activity
	{

		Thread splash;
		protected override void OnCreate(Bundle savedInstanceState)
		{
			base.OnCreate(savedInstanceState);

			// Set our view from the "main" layout resource
			SetContentView(Resource.Layout.Main);
			this.Window.AddFlags(WindowManagerFlags.Fullscreen);            // settting full screen parameters
			this.Window.ClearFlags(WindowManagerFlags.ForceNotFullscreen);  // settting full screen parameters

			splash = new Thread(new ThreadStart(delegate
			{
				try
				{
					Thread.Sleep(3000);
				}
				catch (Exception e)
				{
					e.ToString();
				}
				finally
				{
					StartActivity(new Intent(Application.Context, typeof(Home)));
				}
			}));

		}
	}
}

Now run xamarin splash screen example android application project.

Xamarin Splash Screen,Xamarin Splash Screen example,xamarin splash screen example android,splash screen example android,

that’s it for xamarin splash screen example android tutorial.

Thanks