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 中添加依赖项
如上面的链接所述