Android splash screen is one of the best way to make your android app look more attractive and also a way to advertise your brand in your app. We also use splash screen to load some data from service (http) or run some other process in background or preparing data to show in next activity. In this post we are going to make a splash screen and i also load website in application using webview.

 

Android Splash screen

1. Open your eclipse and create new Android application project { File ⇒ New Android ⇒ Application Project } name your project select icon if you want to change and done.

2. To run splash we create separate class in our package (Splash.java) and also create new activity in layout (splashscreen.xml).

3. Now open activity file (splashscreen.xml) inside layout folder in project and design it and save

splashscreen.xml

Now for creating splash i am using relative layout and add two image and also add background color in my layout. You can design whatever you want to show in your splash.

 Splash.java

In my splash.java i call new handler class and use postDelayed() method to display our splash for some interval of time and when time is out we load our main activity as shown in above code.

Now open your AndroidManifest.xml and register your splash screen activity as first activity

Now you can launch your application in your device or emulator.

Note when you launch your application a for first few second a black screen was appear if your splash screen background have black color its ok but if your theme have some other background you need to create a custom theme to solve that problem.

Code to create a custom theme for splash screen

Now create a new xml file inside values folder and paste use these code

you can define your own style as i create in above xml file and save it now you can call this theme in where you add splash screen activity in AndroidManifest.xml file

And after doing this your problem is solve.

 Working on WebView in Android

WebView is used to display a webpage, maps etc.. before using web view you need to add Internet permission in your AndroidManifest.xml file

before application

MainActivity

This is my main activity class where i load my webview.

In n above code first i remove my default title bar from my mainactivity file using code

Note that you need to call requestWindowFeature() before you setContentView() to remove your title bar.

and next i initialize webview and call some default feature and load url from internet on this application.

activity_main.xml

In my mainactivity.xml i create a webview where i display my site on this application.

You can download this code and try this apk in your android device from link above.

Hope you like.

🙂