Create an eye-catching, beautiful splash activity for your android app in Android Studio. This is a simple way to create a splash activity in Android Studio easily with a minimalistic view…
This article also includes examples of these tutorials:
Running activity in Full Screen
Adding Images for ImageView
Hide the Toolbar/Action Bar in a specific activity
Switching Activities after a specific time
Example of a simple “thread” code
Getting Started – Prerequisite
Before we get started, We will need to set up a few things. Make sure you have properly installed the latest version of Android Studio and Android SDK.
Then either create a new project or open an existing project in Android Studio. Create a new “Empty Activity” naming it ‘SplashActivity‘ and place your app logo or the icon you want to show in your splash screen in your “Drawable” Folder (you can simply copy the logo then click on Drawable Folder from Android Studio and press “Ctrl” + “V” to place it in that folder) and name it “applogo“
Now we are all set and ready to start creating our splash activity.
Designing The Splash Activity
Go to “res > layout” and open “activity_splash.xml” (or open whatever activity layout that you decided to use as a splash activity).
Now Follow the Steps Below:
Change the root layout to “Co-Ordinator Layout“/”Relative Layout” from “Constraint Layout“
Insert/Drag ‘n Drop a “Vertical Linear Layout” inside the root layout. Set both height and width of that Linear Layout to ‘match-parent‘ and gravity to ‘center‘
Then add an “ImageView” inside the Linear Layout and set height and width to ‘120dp‘. Additionally, you can add a TextView or add a margin at bottom of the ImageView or linear view to set the image a little bit up from the Vertical center.
So this is our basic design, we can modify it later according to our needs and beautify it more. Now we will move on to the coding part to make it alive.
Hiding The ActionBar/ToolBar
To make it more professional we must remove the default ActionBar/ToolBar. This can be done both programmatically and by changing themes. You can follow any one of them:
By Changing Theme Styles
By following this you will also hide/disable the default ActionBar/ToolBar for all the activities you have in your project, if you don’t want this you may hide it programmatically instead of by changing themes.
We will use a thread to take the user from our splash activity to another/main activity after 5 seconds/more (up to you). So, Before we Get started we need to import another class as we are going to use intent:
Now, to use a thread we will use these lines inside the ‘OnCreate‘ event and we will name the thread ‘th‘ :
We are all set, now try running the app. You have successfully completed the tutorial and now can create and design any type of Splash activity! Hoorah! Don’t forget to react, comment, and share this post…