【问题标题】:react-native splash screen setupreact-native 启动画面设置
【发布时间】:2017-02-20 12:49:52
【问题描述】:

我尝试了许多不同的插件和指令来制作启动画面,但是当我更改或尝试设置 android-manifest 或我的启动画面样式时出现错误,谁能帮助我逐步准确地设置启动画面或请视频作为教程?

我尝试了以下链接,但在运行-android 时出现错误

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

注意:我想要超过 android

【问题讨论】:

    标签: react-native react-native-android splash-screen


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

    【讨论】:

    • 非常感谢我已经使用过这个,但我想知道如何在没有任何包或任何 JavaScript 代码的情况下为 RN android 制作启动画面?
    • 如果你熟悉 java,很容易用 android native 编写它,不知道这些用 RN 但上面的建议效果很好,你可以用闪屏检查我的应用程序在商店@ 987654323@
    • 谢谢我按照你上面的解释做了,非常感谢
    猜你喜欢
    • 2016-05-04
    • 1970-01-01
    • 2020-10-16
    • 2023-02-21
    • 1970-01-01
    • 1970-01-01
    • 2018-11-20
    • 2017-10-20
    • 1970-01-01
    相关资源
    最近更新 更多