Dependency of using Animated Lottie Files:
implementation "com.airbnb.android:lottie:3.4.0"
Splash Screen XML Code:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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="@color/splashBlue"
tools:context=".MainActivity">
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/lottieAnimationView"
android:layout_width="wrap_content"
android:layout_height="400dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.19"
app:lottie_rawRes="@raw/splash"
app:lottie_autoPlay="true">
</com.airbnb.lottie.LottieAnimationView>
<TextView
android:id="@+id/text_Splash"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="Water Dilevery app"
android:textColor="@color/white"
android:textSize="30sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.496"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/lottieAnimationView" />
</androidx.constraintlayout.widget.ConstraintLayout>
Splash Screen Java Code:
package com.programmingwithus786;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceActivity;
import android.view.WindowManager;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getSupportActionBar().hide();
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
TextView text_splash = findViewById(R.id.text_Splash);
text_splash.animate().translationX(1000).setDuration(1000).setStartDelay(2500);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent i = new Intent(getApplicationContext(),MainActivity2.class);
startActivity(i);
finish();
}
},4000);
}
}