Splash Screen - Android

Splash Screen :

how to display a splash screen for a fixed amount of time when your app starts for e.g. branding reasons. E.g. you might choose to show the splash screen for 3 seconds. However if you want to show the spash screen for a variable amount of time.

splash screen android

Procedure : 

  1. Create new project or open your old Project.
  2. Create Empty Activity in your project. Set the activity name what you want. Example : Splash.java
  3. Open the activity_splash.xml file.
  4. Design Splash Screen.
  5. Go to AndroidManifest.xml and change lanucher activity .MainActivity to .Splash Screen Activiy.
  6. At last we do some code in java.
Frist you need to create or open your project in your android studio. Now you create an Empty Activity for you Splash Screen.

And set launcher Activity is Splash Screen Activity.
Example :
Change Launcher Activity in Manifest

You need to define the spash screen in your layout.xml file.

Go to your splash screen xml file. Example : activity_splash.xml.
activity_splash.xml.
 <?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"  
   android:background="#FFFFFF"  
   tools:context=".Splash">  
   <ImageView  
     android:id="@+id/logo"  
     android:layout_width="100dp"  
     android:layout_height="100dp"  
     android:layout_centerInParent="true"  
     android:src="@mipmap/ic_launcher" />  
   <TextView  
     android:id="@+id/appName"  
     android:layout_width="wrap_content"  
     android:layout_height="wrap_content"  
     android:layout_below="@id/logo"  
     android:layout_centerHorizontal="true"  
     android:layout_marginTop="10dp"  
     android:text="@string/app_name"  
     android:textColor="@color/black"  
     android:textSize="20sp" />  
 </RelativeLayout>  
Do this Splash.java Activity :
 public class Splash extends AppCompatActivity {  
   @Override  
   protected void onCreate(Bundle savedInstanceState) {  
     super.onCreate(savedInstanceState);  
     //for full screen  
     this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);  
     setContentView(R.layout.activity_splash);  
     // For Hide Action Bar  
     ActionBar actionBar = getSupportActionBar();  
     actionBar.hide();  
     //For Splash Screen  
     final Handler handler = new Handler();  
     handler.postDelayed(new Runnable() {  
       @Override  
       public void run() {  
         //Code here  
         Intent myIntent = new Intent(Splash.this, MainActivity.class);  
         startActivity(myIntent);  
         finish();  
       }  
     },5000);  
     //==================================  
   } // OnCreate Method Close Here ========================  
You have to wait 60 seconds.

Generating Source Code Link...

Next Post Previous Post
2 Comments
  • Admin
    Admin July 16, 2023 at 10:13 AM

    দারুন। এটা আমাদের অনেক উপকারে আসবে।

  • MA Ajay Roy
    MA Ajay Roy August 25, 2023 at 8:08 PM

    onake opokar hossa vaya tnx

Add Comment
comment url