Splash Screen Source code Android Studio in java. Progress bar in Splash screen android studio. Just copy and paste.

 Splash Screen Source code Android Studio in java.

Demo Video-

Step 1- Create one empty activity for splash screen. We have given the name to that empty activity is spscreen

Important Note - We have given the project name spproject you can change it as per your project.

Step 2- In spscreen.xml paste to below code as it is. You can change as per your requirement.

spscreen.xml Code

 <?xml version="1.0" encoding="utf-8"?>  
 <LinearLayout  
   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:orientation="vertical"  
   tools:context=".spscreen"  
 >  
   <TextView  
     android:layout_width="match_parent"  
     android:layout_height="wrap_content"  
     android:text="Welcome to Our App"  
     android:gravity="center"  
     android:textSize="40dp"  
     android:textStyle="bold"  
     android:fontFamily="cursive"  
     android:layout_marginTop="150dp"  
     android:textColor="@android:color/holo_red_dark"  
   />  
   <ImageView  
     android:padding="25dp"  
     android:layout_width="match_parent"  
     android:layout_height="wrap_content"  
     android:src="@drawable/img1"  
   />  
   <TextView  
     android:layout_width="match_parent"  
     android:layout_height="wrap_content"  
     android:text="www.informationraja.com"  
     android:gravity="center"  
     android:textColor="@android:color/holo_blue_dark"  
     android:textStyle="bold"  
     android:textSize="20dp"  
   />  
   <ProgressBar  
     android:layout_width="match_parent"  
     android:layout_height="wrap_content"  
     android:layout_marginTop="10dp"  
   />  
 </LinearLayout>  


Step 3- Open the spscreen.java file and paste the below given as it is. You can change the time of splash screen that how much time you have to show the splash screen. After that time it jumps automatically on the mainactivity.

spscreen.java Code

 package com.rush.spproject;  
 import androidx.appcompat.app.AppCompatActivity;  
 import android.content.Intent;  
 import android.os.Bundle;  
 import android.os.Handler;  
 public class spscreen extends AppCompatActivity {  
   @Override  
   protected void onCreate(Bundle savedInstanceState) {  
     super.onCreate(savedInstanceState);  
     setContentView(R.layout.activity_spscreen);  
     Handler handler = new Handler();  
     handler.postDelayed(new Runnable() {  
       @Override  
       public void run() {  
         Intent intent=new Intent(spscreen.this,MainActivity.class);  
         startActivity(intent);  
         finish();  
       }  
     },3000);//Timer you can change time here example-1 sec=1000
   }  
 }  

Step 4 - Make the Below Changes in AndroidManifest.xml file. cut the <intent-filter> ....... </intent-filter> from mainactivity to spscreen activity. So that first the spscreen(i.e Splash Screen) activity will be launched.

AndroidManifest.xml Code

 <?xml version="1.0" encoding="utf-8"?>  
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"  
   package="com.rush.spproject">  
   <application  
     android:allowBackup="true"  
     android:icon="@mipmap/ic_launcher"  
     android:label="@string/app_name"  
     android:roundIcon="@mipmap/ic_launcher_round"  
     android:supportsRtl="true"  
     android:theme="@style/Theme.Spproject">  
     <activity android:name=".spscreen"  
       android:theme="@style/Theme.AppCompat.DayNight.NoActionBar">  
       <intent-filter>  
         <action android:name="android.intent.action.MAIN" />  
         <category android:name="android.intent.category.LAUNCHER" />  
       </intent-filter>  
     </activity>  
     <activity android:name=".MainActivity">  
     </activity>  
   </application>  
 </manifest>  

Before Image AndroidManifest.xml


After Making Changes



Now Run the App all is Done! Best Luck.

More Android Post-

Android Studio TabView Source Code,Android Studio Tablayout Source Code







Post a Comment

0 Comments