Splash Screen creating from another perspective

The other way of creating the Splash Screen is more fast and without using messy layout and splash screen activity files (.xml & .java)

This is a simple example how this is implemented:

First you don’t need to create a separate layout file for the activity, just the theme. Specify your splash screen’s background as the activity’s theme background. To do this, first create an .xml drawable in res/drawable with this code inside. This is used for setting background color (@color/black) & image (@mipmap/ic_launcher where this is the app icon).

You must set this in your main app theme located in res/values/styles.xml and In your new Splash Theme, set the window background attribute to your XML drawable (@drawable/background_splash) with this code:

In your Splash Screen .java file just add this code for automatic forwarding to your Home or Main or whatever you like – Activity .java

You’ll need in onCreate() to make new Intent from THIS activity to, lets say, HomeActivity.class (designated activity must be declared with .class extension)

The method startActivity() is for starting new activity, but it must have a intent parameter that we defined before

And finally finish() method for ending SplashScreen activity so it can be viewed when back button is pressed.

This way is faster because it uses app them as a Splash Screen style, not running the activity layout, so if you initialize something the layout will be delayed after the initialization is implemented and that is not good.

For further research on the Splash Screen:

https://www.bignerdranch.com/blog/splash-screens-the-right-way/

and GitHub:

https://github.com/cstew/Splash

Spread the love

1 Comment

  1. I blog frequently and I truly thank you for your content. The article has truly peaked my interest. I’m going to take a note of your website and keep checking for new details about once per week. I subscribed to your Feed too.|

Leave a Reply

Your email address will not be published. Required fields are marked *