How to Create a Splash Screen
What’s a Splash screen?
It’s a start up screen that is displayed while an android app loads in the background. It can contain your app’s logo and/or name.
There are different ways of creating a splash screen like using timers with an extra activity, but this method can cause the splash screen to display more than necessary. Here, I’ll show you a more appropriate method, using the app’s launcher theme on Android Studio.
- First we want to create a drawable resource file containing the logo and the background color. Add the file in the res/drawable folder.
Ensure you use a layer-list tag to contain your drawable files.
- Next we want to define a theme for the splash screen in theme.xml (in the res/values/themes folder).
Here you specify your drawable resource file as your android:windowBackground
. In this example, I’ll name my theme “splashScreenExampleTheme”.
- Set the app’s the launcher theme to the splash screen theme in AndroidManifest.xml using
android:theme
in the application tag.
- Finally, in your main activity, set the launcher theme back to the app’s default theme, using the
setTheme()
function beforesuper.onCreate(savedInstanceState)
, like so…
Result…
And we’re done!
If you like this article, follow me for more! And leave your comments if you have any.