Ticker

6/recent/ticker-posts

Splash Screen with Animation in Android

Splash Screen with Animation in Android

Splash screen with Animation in Android


In this blog of Android UI, we have discussed how to create a Splash Screen with some Animations.
Splash Screen is the first screen of an app. The splash screen is used to display some basic information about the app, like the brand logo, name, slogan, etc. It's like an introduction to the app.

So, now you are going to create a splash screen, it includes a logo, name, and slogan.
  • Before going to start, copy your logo or image, and paste it in the res/drawable directory.

Paste the image in drawable directory
Paste the image in drawable directory
  • In the splash screen, you don't need Action Bar. So go to the res/values/style.xml file and change the DarkActionBar theme to the NoActionBar theme.
Change DarkActionBar to NoActionBar
Change DarkActionBar to NoActionBar
  • Now open the activity_splash.xml file. In Android Tutorial, Layout in Android blog, we have already discussed how to write XML and what is the need for XML. CLICK HERE to know more.

Create activity_splash.xml file:

activity_splash.xml




XML file elements placing

Create Animation File:
  • You are going to use three animations. Top, Bottom, and Middle Animations.
  • To add animation files, first create the anim directory inside the res folder.
Create anim directory
Create anim directory
  • Create three Drawable Resource File inside anim directory. Right click on anim > New > Drawable Resource File, like this create three files.

top_animation:
Top-animation
Top-animation
bottom_animation:
Bottom-animation
Bottom-animation

middle_animation:
middle_animation
middle_animation


Initialize hooks and functionality:
  • Go to the SplashActivity.java class and create the hooks and initialize the objects with IDs. And set the animation.
set all animation in java file
set all animation in java file
  • Here, top_animation is set with Image, middle_animation with Name, and bottom_animation with the Slogan.
  • We set the SPLASH_TIMEOUT to 4000 i.e 4 seconds. After 4 seconds the Handler will directly bring you to the next activity (here SecondActivity). 
set handler
set handler
  • The handler is associated with the thread and that thread is message queue. That means the handler allows you to send messages.


SplashActivity.java





Output:


click to view




**Hope you like it, if you have any doubt then comment below.



Quick Recap:

  • Splash Screen is the first screen of an app. The splash screen is used to display some basic information about the app
  • Here in the splash screen, three animations are used. Top, Middle, and Bottom animations.
  • For image copy and paste your image in the drawable folder.
  • Use a timeout for the splash screen.
  • The handler allows us to send messages.



Post a Comment

0 Comments