Add Splash Screen To Your Android Application – Part 3

Today I will tell you how to add a splash screen to your Android application. So that if any person opens your Android application, then a loading screen will appear in front of him. You will not face any problems in this whole process.

I am doing all this testing on the application made by me. If you want to know how to convert your website into an Android application, then you can read all the above posts, which will give you an idea of ​​how you can create and modify your own Android application. can.

  1. Install Android Studio On Windows 10 – Part 1.
  2. Convert a Website to Android App – Part 2.
  3. Enable Download Button In Webview Android App 2021 – Part 4.
  4. How to Generate APK for Google Play Console in Android Studio – Part 5.
  5. How To Publish Android App on Google Play Store – Part 6.

Splash Screen To Your Android Application

Splash Screen

First of all, you have to open your Android Studio where you created the source code of your android application. After this, you have to go to New by right-clicking on the Java folder from all the folders given on the left corner.

Then going down and clicking on Activity, after that you have to click on MPT Activity so that you can create a new file on your Android To add an application’s splash screen.

Splash Screen

After doing this, some kind of interface will open in front of you, after coming to this section, you have to replace the activity name with (SplashActivity).

After replacing the activity name, you do not have to change all the option scores given below at all and then save and finish this whole process by clicking on the finish button given at the bottom right corner.

Splash Screen

After doing this, you will see that in addition to the three files of the Android application you have created, there are two more files, in which we will add a splash screen to our Android application by coding a little.

Splash Screen

After creating two new files, you have to open the activity_splash.xlm file and select this plate option made on the right corner. Due to which you can see the live preview of whatever coding you will do in this file on the screen given on the side. And you can find out how the splash screen created by you is working on Android mobile.

Add This Code On Splash Screen

SplashActivity.java

    import androidx.appcompat.app.AppCompatActivity;


    import android.content.Intent;

    import android.os.Bundle;

    import android.view.Window;

    import android.view.WindowManager;


    public class SplashActivity extends AppCompatActivity {


        @Override

        protected void onCreate(Bundle savedInstanceState) {

            super.onCreate(savedInstanceState);


            Window window = getWindow() ;


            window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

            setContentView(R.layout.activity_splash);




            Thread splashTread = new Thread(){


                @Override

                public void run() {

                    try {

                        sleep(3000);

                        startActivity(new Intent(getApplicationContext(),MainActivity.class));

                        finish();

                    } catch (InterruptedException e) {

                        e.printStackTrace();

                    }


                    super.run();

                }

            };


            splashTread.start();





        }


    }

After doing this, now we have to add some codes in both these files, for which you have to copy the above code and then open your Android Studio software again.

Splash Screen

After opening Android Studio, you have to open the SplashActivity.java file out of the new file you have created and then you have to select all the code except the package name and replace it with the copied code.

Keep one thing in mind that you do not have to delete the first line from this file, which is the section of the package, apart from this, you should replace all the codes with the copied code.

activity_splash

    <?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=".SplashActivity">


        <ImageView

            android:layout_width="match_parent"

            android:layout_height="300dp"

            android:src="@drawable/logo"

            android:scaleType="centerCrop"

            android:padding="50dp"

            android:layout_marginTop="220dp"/>

        <ProgressBar

            android:layout_width="220dp"

            android:layout_height="10dp"

            android:layout_gravity="center_horizontal"

            style="?android:attr/progressBarStyleHorizontal"

            android:max="100"

            android:indeterminate="true"

            android:progress="0"

            android:layout_marginTop="100dp"


            />



    </LinearLayout> 

After this, now we have to add another code in our android application, for which you have to copy the above code and open your Android Studio software again.

After opening Android Studio, now you have to open the activity_splash.xlm file. After opening the file, select whatever code is present inside the file, why copy it, and replace it with the code, keep in mind that you have to delete all the code available in the file. And copy and paste the code.

After completing all this process, now you have to add 1 logo to your android application. So that if anyone opens your Android application on your device, then your logo along with the splash screen can also be visible to him.

To add people to the splash screen, keep one thing in mind that the name of the image you are going to use as a logo should be Logo.

To add loco to the splash screen, first, you have to copy the image that you are going to use as people. Keep in mind that the name of the image should be a logo or else this image will not work and no image will say show on your splash screen.

After copying the image, you have to open Android Studio and right-click on the Drawable folder out of all the folders related to your application given on the left side and paste the image you had copied.

After doing this, some kind of interface will open in front of you, here you do not have to make any changes, you have to end this whole process by clicking on the direct OK button.

After clicking on the OK button, some kind of interface will open in front of you, even in this file, you do not have to change any method, if you change anything, then your logo image may get spoiled and that’s after I will not make any difference in your application. After that, you have to click on the OK button.

As soon as you click on the OK button, you will see that the splash screen you have installed in your Android application on the right corner will add 1 logo, which was selected by you if you increase or decrease the size of this logo. If you want, you can do it by going to the section on Padding given below.

AndroidManifest.xml

<activity android:name=".MainActivity"></activity>
<activity android:name=".SplashActivity">

            <intent-filter>

                <action android:name="android.intent.action.MAIN" />


                <category android:name="android.intent.category.LAUNCHER" />

            </intent-filter>

        </activity>

After doing all this process, now you have to change some codes in your android application, for which you have to copy the above code and then open your Android Studio.

After opening Android Studio, now you have to open the AndroidManifest.xml file and replace some of the lines shown in the photo with the copied lines.

Keep in mind that the line you see in the image you have to replace only those lines with the copied lines, otherwise there may be some problem in the code of your Android application and your Android application will not work properly.

After doing all this process, now as soon as you open your Android application, you will see that the splash screen you have set has been started in your Android application and if you want to change the timing of this splash screen then You can change this by going to the code of your Android application, which you will find in the two new files that you have created.

Time of FAQs

How do I add a splash screen to an existing project?

If you have created an android application and you want to add a splash screen in it, then for that you have to create a new file inside which you can add some source code and do some editing in that source code to add splash screen in your android application can enable. You can also use android-studio to enable a splash screen, inside which you can edit the source code of your Android application.

What is the splash screen in Android?

The splash screen is the 1st loading screen which is shown first when you open your Android application, where your Android application call or your organization’s logo is shown to the user for a few seconds. You can easily change the splash screen and easily install it on your Android mobile. There are many benefits of using the splash screen, so you can promote user engagement and your company whenever someone visits your company. If the logo sees, then some questions related to your company will come to his mind and he will definitely visit your official website.

1 thought on “Add Splash Screen To Your Android Application – Part 3”

Leave a Comment