How to add splash screen in webview app

How to add splash screen in web view app 





Just follow the steps told in the video


Copy and paste all the codes of  SplashActivity.java


import androidx.appcompat.app.AppCompatActivity;


import android.content.Intent;

import android.os.Bundle;

import android.view.Window;

import android.view.WindowManager;


public class SplashActivity extends AppCompatActivity {


    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);


        Window window = getWindow() ;


        window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.activity_splash);




        Thread splashTread = new Thread(){


            @Override

            public void run() {

                try {

                    sleep(3000);

                    startActivity(new Intent(getApplicationContext(),MainActivity.class));

                    finish();

                } catch (InterruptedException e) {

                    e.printStackTrace();

                }


                super.run();

            }

        };


        splashTread.start();





    }


}




paste these codes in activity_splash


<?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">


    <ImageView

        android:layout_width="match_parent"

        android:layout_height="300dp"

        android:src="@drawable/fizz_blogging"

        android:scaleType="centerCrop"

        android:padding="50dp"

        android:layout_marginTop="20dp"/>

    <ProgressBar

        android:layout_width="220dp"

        android:layout_height="10dp"

        android:layout_gravity="center_horizontal"

        style="?android:attr/progressBarStyleHorizontal"

        android:max="100"

        android:indeterminate="true"

        android:progress="0"

        android:layout_marginTop="300dp"


        />



</LinearLayout> 



Paste these codes in manifest 

<activity android:name=".SplashActivity">

            <intent-filter>

                <action android:name="android.intent.action.MAIN" />


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

            </intent-filter>

        </activity>



Thx 

Post a Comment

0 Comments