Best Practice to Implement Splash Screen in Android.
By: Pranjal Gupta
Tags: UX, Android App Design, Android, Android Apps, Ui Ux Design

Every Developer and User want its app to launch right-away after it is clicked, and that totally not possible at least not on cold start. The fundamental idea of splash screen in application is to engage user to watch something ; rather than staring at the damn grey/white screen for the while it takes the activity and its view to render and replace the splash screen. This is a bad UX practice and user might feel that the app is not responsive.

Not the best practice, white screen opens first

Whats Wrong

I have seen some good apps and tutorials make this mistake of making the thread of the splash screen sleep by 1–2 sec for the sake of showcasing a Splash Screen and branding. Unfortunately, developers often implement splash screen as Activity which itself takes time to render, further destroying the purpose of splash screen itself, which is then followed a Thread.sleep(TIME_IN_MILS) and then taking the user to the Main Activity.

Best Practice

The amount of the time splash screen shows itself should be the amount of time it takes the app to configure itself for the user to use, especially on a cold start(which can take a good amount of time).

Splash Screen opens right away

Implementation

So instead of using the layout file, we will specify splash screen as background of the activity theme. First create splash_background.xml in

<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">



<item android:drawable="@color/white" />





<item android:drawable="@drawable/ic_icon_vector"

android:gravity="center"/>



</layer-list>

Then setting this drawable in res/styles.xml as android:windowBackground of the activity.

<!-- Splash Screen theme. -->

<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">

<item name="android:windowBackground">@drawable/splash_background</item>

</style>

Add your theme in manifest as your splash activity theme.

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.androidjavapoint.splashscreen">

<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".SplashActivity" android:theme="@style/SplashTheme">

<intent-filter>

<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />

</intent-filter>

</activity>

<activity android:name=".MainActivity" /> </application>

</manifest>

Now comes the ScreenActivity.java , which will not use any setContentView(R.layout.activity_welcome) as we dont want any layout to inflate, just the background.

public class WelcomeActivity extends AppCompatActivity { @Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);



startActivity(new Intent(WelcomeActivity.this, MainActivity.class));

finish();

}

Final Result

Final app splash screen

This is the best practice to make your look and feel responsive to the user using a splash screen that launches right away after you have the launched the app.

Hope using this article you will be able make your splash screen work in a right way.

Thanks for reading. To help others please click ❤ to recommend this article if you found it helpful.