An Android app takes some time to start up, especially when the app is first launched on a device. A splash screen may display start up progress to the user or to indicate branding.

Here’s how you will be able to create a splash screen:

Step 1: Create a Drawable for the Splash Screen Visual

Here we are creating a drawable using xml, lets call it splash_screen.xml. The intent is to add a background color and a image to this visual. You can point the color to any color resource as well.

splash-screen-drawable

Step 2: Add a Style Theme

We now need a theme for the splash screen. This is required so that we can tell the activity created below to add a ‘background’ using the above drawable.

splash-screen-style

Add the Style snippet to your styles.xml

Step 3:Create a Splash Activity

The last step is to add an activity to your Xamarin Android project.

You can do background work in this activity before you start the main activity. In my case, I just wanted to have a splash screen show up until the Xamarin.Forms app loads into the view.

splash-screen-activity

So in the ‘OnResume’ method, I start my original activity. Make sure to mark this activity as the MainLauncher. Also mark your original main activity as MainLauncher=false.

This is how my Splash Screen looks:

Screenshot_20161211-085539.png  Screenshot_20161209-203905.png

See this post on Xamarin Guides for a complete step by step walkthrough.

Advertisements

Share your thoughts

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s