Header Ads

Header ADS

How to set up Splash screen in android studio?

#Splash screen in android studio. Wow!


If you want to show splash screen for some time with lottie animation while entering your android app then this post is for you. How to create a splash screen for some time is described below.

Follow this procedure:
1.First of all go to Lottie Animation website and download a Lottie file of your choice. And rename that Lotti file name.
2.Create your new project or open your old project that you created before.
3.Create a new Activity and set the name of that activity.
for example: Home_Activity.java
4.Go to buold.gradle  and Sync now by entering the code given below. (for lottie animation) for Example:
5.Open the activity_home.xml file and Click on res> new> directory and create raw file.
keep here your lottie files. for Example:
6. At last go to your Home_Activity and do this blew cods.
for Example:


for build.gradle
//for lottieanimation
     implementation "com.airbnb.android:lottie:5.2.0"
     
for activity_....xml
//for xml
<?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"
tools:context=".Home_Activity"
android:orientation="vertical"
android:gravity="center"
android:background="#FFFFFF"
>

<com.airbnb.lottie.LottieAnimationView
android:id="@+id/animationView"
android:layout_width="300dp"
android:layout_height="300dp"
app:lottie_rawRes="@raw/loading"
app:lottie_autoPlay="true"
app:lottie_loop="true"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Welcom to CM Coding Lab!"
android:textSize="25dp"
android:textColor="@color/teal_200"
android:gravity="center"
android:textStyle="italic"
/>


</LinearLayout>
for your ....._Activity.
//in Java===============================================
//for full screen
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);

// For Hide Action Bar
ActionBar actionBar = getSupportActionBar();
actionBar.hide();

//For Splash Screen
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
// Do something after 5s = 5000ms
// এখানে কাজটা করবেন যা 5েকেন্ড পরে শুরু হবে।

//startActivity(new Intent(Home_Activity.this,MainActivity.class));
finish();
}
}, 5000);

           **If you have any problem, to get help you can watch this video. thank you.**



No comments

Custom alert dialogue in Android studio Java.

                               Custom alert dialogue in Android studio Java.   Hello friend welcome to CM coding l...

Theme images by Jason Morrow. Powered by Blogger.