AndroidPub
Published in

AndroidPub

Splash Screen in Android: The Right Way

After a research, I’ve found a lot of tutorials about splash (or launch) screen implementations on Android, but developers usually add a Runnable with a fixed time as delay to solve it. That solution was not an option for me, because I don’t want to force my app users to wait when there is nothing to load actually. Let me show you a great solution with minimal modifications that shows the splash screen while the app is loading.

This is what I’ve done in that way

Let’s code

First, we have to design the splash screen layout as a drawable. I’ve used my app logo as the center bitmap, and the primary color as background.

Now, we need to define a theme with the windowBackground value as the previous drawable.

Then, the theme must be assigned to the Main activity.

Finally, we have to replace the splash theme with the original of the Main activity.

Conclusion

With this approach, the splash screen is showed during the app initialization when it’s useful. Also, there is no need to create an extra activity to launch the splash, preventing delays associated with the activity creation. Keep the splash drawable as simple as possible, and you’ll love how fast it works.

That’s all folks!

--

--

--

The (retired) Pub(lication) for Android & Tech, focused on Development

Recommended from Medium

Setting up a continuous integration system on Android using CircleCi 2.0

CRODO association with GAUR Money:

Asymmetric encryption: a JavaScript and PHP example

How To Create a Valid HTML Web Page With Elements

How to Create a Valid HTML Web Page

$CRODO Ambassador Program — New age, New standards, New appraisal.

PARSIQ Q&A #24

Topcoder SRM 798 DIV 2 — Problem 500

What is Difference between Ruby Blocks, Procs and Lambdas

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Pablo Pallocchi

Pablo Pallocchi

Co-Founder at Jipink

More from Medium

Understanding User Permissions in Android

Using Huawei App Messaging in Android

Espresso UI Testing for Intents in Android

Android ViewModel and ViewModel Factory