This is Sample Project Which you can improve UI design & Coding skills .
*This splash screen Connected to Tutorial 1.*
1)You need add this dependencies to build.gradle.
"implementation 'com.airbnb.android:lottie:3.4.1'"
You need to Download and paste these folder to your "res" folder.
If you get any trouble. Please Contact me on WhatsApp!!
SplashActivity
activity_splash
package com.rrmchathura.myfirstapp;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.view.WindowManager;
public class SplashActivity extends AppCompatActivity {
SharedPreferences MainActivity;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_splash);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
MainActivity = getSharedPreferences("onBordingScreen",MODE_PRIVATE);
boolean isFirstTime = MainActivity.getBoolean("firstTime",true);
if (isFirstTime){
SharedPreferences.Editor editor = MainActivity.edit();
editor.putBoolean("firstTime",false);
editor.commit();
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent);
finish();
}
else {
Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
startActivity(intent);
finish();
}
}
},3000);
}
}
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.view.WindowManager;
public class SplashActivity extends AppCompatActivity {
SharedPreferences MainActivity;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_splash);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
MainActivity = getSharedPreferences("onBordingScreen",MODE_PRIVATE);
boolean isFirstTime = MainActivity.getBoolean("firstTime",true);
if (isFirstTime){
SharedPreferences.Editor editor = MainActivity.edit();
editor.putBoolean("firstTime",false);
editor.commit();
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent);
finish();
}
else {
Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
startActivity(intent);
finish();
}
}
},3000);
}
}
<?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">
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/lottie"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="2dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.25"
app:lottie_autoPlay="true"
app:lottie_repeatMode="restart"
app:lottie_repeatCount="1000"
app:lottie_rawRes="@raw/shop" />
</LinearLayout>
<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">
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/lottie"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="2dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.25"
app:lottie_autoPlay="true"
app:lottie_repeatMode="restart"
app:lottie_repeatCount="1000"
app:lottie_rawRes="@raw/shop" />
</LinearLayout>
0 Comments