
Splash Screen in Android
Splash Screen is most commonly the first startup screen which appears when App is opened. it is a simple constant screen for a fixed amount of time which is used to display the company logo, name, advertising content etc.
Splash Screen is show when app is first time launched on your device or it may some kind of process that is used to show Splash screen.
Splash screen are used to background process of Like thread,Handler etc in android used. In this Methods is some time to open screen and then close screen to start app in you device.
How to Make Splash Screen in Android ?
You can different different method of making splash screen.Like Thread,Handler etc. In this methods used to making of splash screen and it is background process in splash screen.
Example of Splash Screen in Android
Create activity_main.xml File Follow this Code.
1 2 3 4 5 6 7 8 9 10 |
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" android:background="@drawable/splashnew"> </RelativeLayout> |
Create MainActivity.java File Follow this Code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
package com.bhaumik; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); getSupportActionBar().hide(); Thread thread = new Thread(){ @Override public void run() { try { sleep(5000); startActivity(new Intent(MainActivity.this,FirstActivity.class)); finish(); } catch (InterruptedException e) { e.printStackTrace(); } } }; thread.start(); } } |
In this Example of Create Splash Screen in android. it can define in Thread and implement run() method. in this method used to declare try catch block and sleep() method. in this method to display Splash screen in some time and then start thread and declared millisecond time to stop thread and open another activity.