How to link splash scree to android application

 

How to link splash screen to  android application

Hello All, 

Today's Topic is splash screen in react native. We are going to add a splash screen to the mobile application.

let's start with the code =>

Step 1: Let's Create a react-native project.

 react-native link react-native-splash-screen

 i am using this image as splash screen

Step  2: Create folder in android/app/src/main/res

 name drawable

 paste your image in that folder

 name image launch_screen.png

Step 3: Create folder layout in res and create file launch_screen.xml in it 

  and paste below code in it


HTML Code

Step 4: Write below code 

  <?xml version="1.0" encoding="utf-8"?>

  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:orientation="vertical" android:layout_width="match_parent"

    android:layout_height="match_parent">

    <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:src="@drawable/launch_screen" android:scaleType="centerCrop" />

</RelativeLayout>


 

Step 5:  Write below code in MainActivity.java

 import org.devio.rn.splashscreen.SplashScreen;

import android.os.Bundle;

public class MainActivity extends ReactActivity {


   @Override

  protected void onCreate(Bundle savedInstanceState) {

      SplashScreen.show(this);  // here 

      super.onCreate(savedInstanceState);

  }

}

 

Step 6 : Now edit MainApplication.java and paste the below code in it

import org.devio.rn.splashscreen.SplashScreenReactPackage;

new SplashScreenReactPackage();

edit app.js

import SplashScreen from 'react-native-splash-screen';

  componentDidMount(){

    SplashScreen.hide();

  }






Comments