I wanted to make my app look more professional, so I decided that I wanted to make a splash screen.
How would I create it and then implement it?
I wanted to make my app look more professional, so I decided that I wanted to make a splash screen.
How would I create it and then implement it?
This is the full code here
SplashActivity.java
In drawables create this bg_splash.xml
In styles.xml create a custom theme
and finally in AndroidManifest.xml specify the theme to your activity
Cheers.
Create an
Activity
SplashScreen.java
splashscreen.xml
will be like thisAnother approach is achieved by using CountDownTimer
Splash screen is a little unusable object in Android: it can not be loaded as soon as possible for hiding the delay of main activity starting. There are two reasons to use it: advertising and network operations.
Implementation as dialog makes jump without delay from splash screen to main UI of activity.
Layout:
And start:
Create a Activity, let us Activity named 'A', then create a xml file called myscreen.xml, in that set a the splash screen image as background, and then use count down timer to navigate from one Activtity to another. To know how to use Count Down timer see my answer in this question TimerTask in Android?
In my case I didn't want to create a new Activity only to show a image for 2 seconds. When starting my
MainAvtivity
, images gets loaded into holders using picasso, I know that this takes about 1 second to load so I decided to do the following inside my MainActivityOnCreate
:When starting the application the first thing that happens is the
ImageView
gets displayed and the statusBar is removed by setting the window flags to full screen. Then I used aHandler
to run for 2 seconds, after the 2 seconds I clear the full screen flags and set the visibility of theImageView
toGONE
. Easy, simple, effective.