How To Make Animated Splash Screen In Android Studio || Spike World || 2021

How To Make Animated Splash Screen In Android Studio || Spike World || 2021

A Splash-Screen is in most cases the primary display screen of the app whilst it is opened. It's far a steady screen which seems for a particular quantity of time, typically shows for the primary time whilst the app is released. The splash display screen is used to show some basic introductory data along with the business enterprise logo, content, and so on just before the app masses absolutely.

Lets Started!!!!


Step 1: Create New Project.

First of all open android studio and click on “Start a new Android Studio project”. Choose to add an Empty Activity to the project and click next, you can name it Splash Activity. Your project should look like the picture below after the Gradle build is finished.





Step 2: Create An Animation.

First we create a folder for animated xml file for that right click on res > New > Android Resource Directory put name "anim" click finish. After creating directory we create animated xml file name is " top.xml " and " bottom.xml ". Your Project look like this.


 

 Then, put the following code into the top.xml file:


<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="1500"
android:fromXDelta="0%"
android:fromYDelta="-50%" />
<alpha
android:duration="1500"
android:fromAlpha="0.1"
android:toAlpha="1.0" />


</set>

 Then, put the following code into the bottom.xml file:


<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">

<translate
android:duration="1500"
android:fromXDelta="0%"
android:fromYDelta="100%" />
<alpha
android:duration="1500"
android:fromAlpha="0.1"
android:toAlpha="1.0" />
</set>
 
 

Step 3: Create Drawable.

After creating animation now we are creating drawable xml file for that go to res right click on drawable and create xml file. Give name splash_bg.xml. Your project looks like below.




Then, put the following code into the splash_bg.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#34495e"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>
 

Step 4: Create an XML Activity.

After that go to res > layout > and open activity_splash.xml file and then, put the following code into it:

<?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"
android:layout_gravity="center"
android:background="@drawable/back_screen"
android:gravity="center"
tools:context=".Splash">

<ImageView
android:id="@+id/imageView"
android:layout_width="300dp"
android:layout_height="250dp"
android:src="@drawable/moneygain"
/>

<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:fontFamily="@font/bungee"
android:text="CudoEarn"
android:textAlignment="center"
android:textColor="#ffffff"
android:textSize="50dp"
android:textStyle="italic" />

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15dp"
android:text="Copyright: 2021"
android:textAlignment="center"
android:textColor="#ffffff"
android:layout_marginTop="10dp"
/>


</LinearLayout>



 

Download Bungee font from here


Step 5: Create an JAVA Activity.

After that go to Java > com.xyz.spikeworld > and open SpalshActivity.java file and then, put the following code into it:


package com.xyz.spikeworld;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.TextView;


public class SplashScreen extends AppCompatActivity {

    private  static  int SPLASH_SCREEN =5000;

    ImageView imageView;
    TextView textView1, textView2;
    Animation top, bottom;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_splash_screen);


        imageView = findViewById(R.id.imageView);
        textView1 = findViewById(R.id.textView);
        textView2 = findViewById(R.id.textView2);


        top = AnimationUtils.loadAnimation(this, R.anim.top);
        bottom = AnimationUtils.loadAnimation(this, R.anim.bottom);
        imageView.setAnimation(top);
        textView1.setAnimation(bottom);
        textView2.setAnimation(bottom);

        new Handler().postDelayed(new Runnable()
        {
            @Override
            public void run() {
                Intent intent = new Intent(SplashActivity.this, MainActivity.class
                startActivity(intent);                
                finish();
            }
        },SPLASH_SCREEN);

    }
}

 
 

Step 6: Replace the default launcher.

Now add below line into manifest.

<activity android:name=".SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

That's it now run the project.

Download Full Source Code From Here



Post a Comment

Post a Comment (0)

Previous Post Next Post