How can you create a splash screen in Xamarin forms?

create a splash screen in Xamarin forms

Introduction – A splash screen is an image or Splash Screen is a better way to promote your application and gives people a warm welcome at the start or page that shows up when you first load your app. When the application is initializing, Xamarin Forms do not have any functionality to add a splash screen. You should do this with the platform.

Need an expert Xamarin App Development Services? Consult Inwizards Now!

Screen: Splash Screen

splash screen in Xamarin forms

 

Creating the Project

Open Visual Studio Community 2017 and click New Project. Select Visual C# >> Cross-Platform template >> Blank App (Xamarin.Forms Portable).

Step 1. Go in the Android project.


Create new class SplashScreen.cs

SplashScreen.cs

 

Step. 2 Add a some code in SplashScreen.cs .

using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;

namespace LetsCookApp.Droid
{
[Activity(Label = “App2”, MainLauncher = true, NoHistory = true, Theme = “@style/Theme.Splash”, ConfigurationChanges = ConfigChanges.ScreenSize)]

public class SplashScreen : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Simulate a long loading process on app startup.
StartActivity(typeof(MainActivity));
Finish();
}
}
}

Step 3. Go in the Android project.

Edit in MainActivity.cs file

Go in the Android project

In App default MainLauncher = true, chamge to MainLauncher = false. Show in above screenshort.

Step 4. Add some code in the Styles.xml file.

In Android project.

=> App2.Droid >> Resources >> values >> c

Figure 1:

styles.xml

 

Figure 2: In styles.xml file

In styles.xml file

 

Step 5 . Add some code in styles.xml above in screen.

<style name=”Theme.Splash” parent=”android:Theme”>
<item name=”android:windowBackground”>@drawable/icon</item>
<item name=”android:windowNoTitle”>true</item>
<item name=”android:windowIsTranslucent”>false</item>
<item name=”android:windowIsFloating”>false</item>
<item name=”android:backgroundDimEnabled”>true</item>
</style>


In the above screen line number 2 ( @drawable / icon) in place of icon you can change and set

“your screen name” Ex:- splash.png

Step 6. Create a splash screen image in the following sizes. 

MDPI is = 320x480px
XHDPI is 2 x MDPI = 640x960px
XXHDPI is 3 x MDPI = 960x1440px
XXXHDPI is 4 x MDPI = 1280x1920px

Hopefully, this will help you to understand and we have successfully created a Xamarin. Forms splash screen. If you are looking forward to Hire Xamarin Developers. Consult Inwizards Now!

 

How can you create a splash screen in Xamarin forms?

Post navigation


0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x