Step-by-Step Tutorial to make an Unlock Splash Screen Android Application
Demo video of the App that will get created by following below tutorial:-
If you want a similar background as I have used in the app, here's the image that you can paste in the drawable folder,
If you want a similar background as I have used in the app, here's the image that you can paste in the drawable folder,
Step 1:- Create a new android studio project.
Step 2:- Now add the following dependency “ maven {url "https://jitpack.io"} ” in project-level Gradle file:-
allprojects {
repositories {
jcenter()
maven {url "https://jitpack.io"}
}
}
Step 3:- Add the following library in the module-level gradle file:-
compile 'com.github.cortinico:slidetoact:v0.1.0'
Step 4:- Create a UI for activity_main.xml as follows:-
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@drawable/sunrise"
tools:context="com.example.himalayabhagwani.unlocksplashscreenapp.MainActivity">
<com.ncorti.slidetoact.SlideToActView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="16dp"
android:id="@+id/slide_to_unlock"
android:elevation="10dp"
app:area_margin="8dp"
app:inner_color="#424242"
app:outer_color="#90FFFFFF"
app:text="Slide to unlock..." />
</RelativeLayout>
Step 5:- Create a new activity “HomeScreen” which will be traversed to after the slider slides on “activity_main.xml” :-
In activity_home_screen.xml,
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/sunrise"
tools:context="com.example.himalayabhagwani.unlocksplashscreenapp.HomeScreen">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="HOME \n SCREEN"
android:textSize="60sp"
android:textColor="#ffffff"
android:fontFamily="cursive"
android:textStyle="bold"/>
</RelativeLayout>
Step 6:- Now just add a OnSlideCompleteListener on the slider in MainActivity.java
In MainActivity.java,
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.ncorti.slidetoact.SlideToActView;
import org.jetbrains.annotations.NotNull;
public class MainActivity extends AppCompatActivity {
SlideToActView slideToActView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
slideToActView = (SlideToActView) findViewById(R.id.slide_to_unlock);
slideToActView.setOnSlideCompleteListener(new SlideToActView.OnSlideCompleteListener()
{
@Override
public void onSlideComplete(@NotNull SlideToActView slideToActView) {
startActivity(new Intent(MainActivity.this,HomeScreen.class));
}
});
}
@Override
protected void onResume() {
super.onResume();
slideToActView.resetSlider();
}
}
Thank you for visiting my blog..!!
Comments
Post a Comment