There are many ways you can create android splash screen. and most of developers using a runnable with post delay, as a result we get splash screen for fixed time, no matter how long app is actually loading at a time of launch.

But this implementation play it’s role once app launch process is finished. So probably there is blank(or white) screen while app is actually loading. To overcome this and display splash screen while app is going through real loading, we are going to implement android splash screen in the right way.




let’s program android splash screen with android studio.

First we create a drawable background for splash screen. In which we are going to use logo as bitmap with center position and white color as background. Make sure you have created your logo or splash image for different screen sizes like mdpi, hdpi, xhdpi, xxhdpi etc.

splash_screen_background.xml

colors.xml

Now we create a theme in styles with the windowBackground value as the above created drawable.

styles.xml

Then, we assign this theme to our main activity in the AndroidManifest.xml file.

AndroidManifest.xml

Last, we have to replace this splash screen theme with the app theme in the main activity.

MainActivity.java

And done, no more blank screen at the time of app initialization. following is the output.

Android Splash Screen - Infinity Android

Also, there is no need to create an activity for splash screen,¬† and yes make sure the splash drawable is as simple as possible. You can use whatever color you want as splash background and also image instead of logo. But don’t forget to make splash image or logo in different screen size to avoid image crop or¬†partial fill.