메뉴 건너뛰기

자료실

DATA

리액트 네이티브 스플레쉬 정리

소프터 2020.08.27 20:57 조회 수 : 2


 

 

npm i react-native-splash-screen --save

react-native link react-native-splash-screen



// layout 생성 
// launch_screen.xml 

drawable 파일에

splash.jpg 넣어줌

//이거 launch_screen 복붙

<?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/splash">
</LinearLayout>

 

메인 엑티비티

 

package com.rpcyeoju;

import android.os.Bundle;

import com.facebook.react.ReactActivity;

import org.devio.rn.splashscreen.SplashScreen;

public class MainActivity extends ReactActivity {

  /**
   * Returns the name of the main component registered from JavaScript. This is used to schedule
   * rendering of the component.
   */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    SplashScreen.show(this);
    super.onCreate(savedInstanceState);
  }
  @Override
  protected String getMainComponentName() {
    return "rpcyeoju";
  }
}