How to do Splash Screen in Android Studio (URL to App Converter)

Welcome to the most interactive tutorial of the Android Studio.

How to do Splash Screen in Android Studio (URL to App Converter)

Hey daily digest, as you must be aware that recently we had taught you how to convert website to app and make Android app through Android Studio. And today we will teach you How to do Splash Screen in Android Studio. So without wasting further time let's get started but before that let's take a overview of Android Studio.

What is Android Studio?

Android Studio is a specially designed IDE (Integrated Development Environment) for android development like Android apps. Google & JetBrains officially released Android studio on June 2014. Android studio is used for creating and building high quality apps. Android studio supports different operating systems like Windows, macOS, lunix and Chrome OS.

Now, let's discuss about how to create splash screen in Android studio.

How to create a Splash Screen in Android Studio

Here, we will discuss step by step guide to create a splash screen in Android studio;

1. First, Go to Android Studio and open the recently created project file.

2. Now, you have to create new Android activity - for this, Right click on Java folder > New > Activity > Empty Activity.

How to do Splash Screen in Android Studio (URL to App Converter)

3. After that, create a new activity name i.e., SplashActivity then click Finish to create a new splash activity file.

How to do Splash Screen in Android Studio (URL to App Converter)

4. Now you will see that both SplashActivity.xml and SplashActivity.java files will be generated automatically in your current project. For now click on the SplashActivity.xml file and select the split option given on the right side.

How to do Splash Screen in Android Studio (URL to App Converter)

5. Now, Click on SplashActivity.java and replace all coding starting from import... with new codes!!! Get code;

 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();






        }



    }

How to do Splash Screen in Android Studio (URL to App Converter)

6. Come back to the SplashActivity.xml file and replace all the codes given here with the new codes. Get 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=".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>

How to do Splash Screen in Android Studio (URL to App Converter)

7. Now, its time to upload a image for Splash Screen. For this go to file explorer and select and copy image then come back to Android studio and then right click on drawable > paste.

How to do Splash Screen in Android Studio (URL to App Converter)

8. Here choose the destination directory for image and click Ok button.

How to do Splash Screen in Android Studio (URL to App Converter)

9. Now, set a name for the splash screen image. Such like logo.jpg then click Ok button.

How to do Splash Screen in Android Studio (URL to App Converter)

All right!!! The splash screen image has been successfully set on your Android app.

How to do Splash Screen in Android Studio (URL to App Converter)

10. Now, you have to do some minor changes in AndroidManifest.xml. You just have to write MainActivity instead of SplashActivity and write SplashActivity instead of MainActivity. If you face problem in this then you can take help from the image given below;

How to do Splash Screen in Android Studio (URL to App Converter)

12. Just click on Play button & overview your splash screen.


Note: Sometimes two icon appears when you create your apk or when you are checking your application. So, to solve this issue you have to follow these steps which are as;

- Firstly open AndroidManifest.xml of your app.

- Now, scroll down. Here, you will see this code.

 <intent-filter>

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

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

      </intent-filter>

- Now, just delete this code.


Conclusion

Above we have discussed the tutorial for how to do splash screen in Android studio. Android Studio is a specially designed IDE (Integrated Development Environment) for android development like Android apps. Google & JetBrains officially released Android studio on June 2014. Android studio helps in creating and building high quality apps. By following above mentioned steps anyone can easily create a splash screen in Android studio.

Related Posts

Post a Comment