~经言/歌词~

I find that the harder I work, the more luck I seem to have.
~ Thomas Jefferson (1743-1826)

Wednesday, November 23, 2011

Android: Splash Screen

I guess almost every app has its own splash screen, maybe by showing the title of the app in an interesting way, or promoting own company or own production, but an interesting splash screen had became a must-have component to show some sophistication of the product.

As usual, starts with creating a new project. 
Remains the originally created .java file and main.xml file untouched.


We need a splash screen page and a main page, and since we already had the main page when we first created the project, we need to create another class file for the splash screen page.

Hence, the next step is to create a new layout and a new page for the splash screen. Dont forget to include an image into the @drawable folder. I named the layout as splash.xml.


After that, i create a new page for the splash screen and i named the class file as SplashClassApp.


Splash screen will disappear itself after few seconds, hence, we need to apply Thread activity to initialize the splash screen activity. In the code above, the splash screen will display for 5 seconds, sleep(5000), and once it is done, the app will continue with the next activity which is showing the first page of the app, by the codes below,

One thing to bear in mind, when we first created the project, the originally created page will always serve as the first page to be displayed when we execute the app. Splash screen however should display before anything else, so now, we need to change the manifest.xml, to alter the order of the page displaying.


And that's it. You will have ur app with a nicely designed splash screen!!!



2 comments:

Catherine said...

Thanks for your sharing. Recently kind of busy with projects at office. Already long time didn't touch the Android since my last work at Android Dashboard.

Good Work. Keep it up!!

维整 said...

haha, i also didnt touch the android these days...

waiting for u to post some posts also...