react-native闪屏设置

时间:2017-02-20 12:49:53

标签: react-native react-native-android

我尝试了许多不同的插件和指令来执行启动画面但是当我更改或尝试设置android-manifest或我的启动画面风格时我收到错误,任何人都可以帮我一步一步准确设置启动画面或者视频作为教程请 我累了这么下面的链接,但是当我运行android时,我遇到了错误

https://android.jlelse.eu/change-splash-screen-in-react-native-android-app-d3f99ac1ebd1#.saf96u3bp

注意:我想要超过android

1 个答案:

答案 0 :(得分:1)

1>使用模块react-native-smart-splash-screen将其安装到您的项目中 2>在MainActivity.java文件中将代码更新为

import com.reactnativecomponent.splashscreen.RCTSplashScreen;
import android.os.Bundle;
import android.content.Intent;
in the onCreate method delete the method and copy the code below

@Override
protected void onCreate(Bundle savedInstanceState) {
RCTSplashScreen.openSplashScreen(this);  
super.onCreate(savedInstanceState);
}
MainApplication.java文件中的

import com.reactnativecomponent.splashscreen.RCTSplashScreenPackage;

replace the getPackages() method with the following


     @Override
protected List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(
      new MainReactPackage(),
        new VectorIconsPackage(),
        new MapsPackage(),
        new RCTSplashScreenPackage()
  );
}

现在在您的目标应用中的着陆页

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


in the lifecycle method componentWillMount() add the following as:



  componentDidMount(){
   SplashScreen.close(SplashScreen.animationType.scale, 2000, 800)
 }

如果有问题请访问此回购

https://github.com/UjjwalNepal/Dental

https://github.com/react-native-component/react-native-smart-splash-screen

在gradle设置中添加上面链接中提到的依赖项,并在android / app / build.gradle中添加依赖项 如上面链接中所述