在React Native 0.57中添加启动屏幕

时间:2018-09-16 17:24:11

标签: reactjs react-native

我只想问一下在react-native中添加初始屏幕的最新方法是什么。我正在使用反应本机的0.57版本并尝试过npm的react-native-splash-screen软件包。谢谢

1 个答案:

答案 0 :(得分:0)

1)按照here的步骤进行链接。

2)编辑MainActivity.java (ProjectName / android / app / src / main / java / com / ProjectName / MainActivity.java)

package com.myproject;
import android.os.Bundle;

import com.facebook.react.ReactActivity;
import org.devio.rn.splashscreen.SplashScreen; 

public class MainActivity extends ReactActivity {
    /**
     * For showing launch image using react-native-splash-screen
     */
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        SplashScreen.show(this);  
        super.onCreate(savedInstanceState);
    }
    /**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */
    @Override
    protected String getMainComponentName() {
        return "MYPROJECT";
    }
}