RN配置启动页,解决app启动白屏问题,实现启动页全屏展示

本文记录配置 andriod app 启动页
环境:react-native: 0.70.4
机型:小米10
参考:https://www.jianshu.com/p/251d1c5dc0db

1、最简单配置

文件位置 android\app\src\main\res\values\styles.xml

配置代码展示

<resources>
    <style>
    	<item name="android:windowDisablePreview">false</item>
        <item name="android:windowTranslucentNavigation">true</item>
        <!-- 设置状态栏颜色,解决其影响启动页全屏展示问题 -->
        <item name="android:statusBarColor">@android:color/transparent</item>
        <item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
        <item name="android:windowBackground">@drawable/launch_screen</item>
    </style>

</resources>

2、实现手动控制关闭启动页

懒得写>_>配置参考:https://www.cnblogs.com/fe-linjin/p/10685676.html

文件目录

在这里插入图片描述

手动关闭示例

调用上面配置时注册的SplashScreenModule原生模块暴露的接口

// src\pages\home\index.jsx
  import { NativeModules } from 'react-native';
  const { SplashScreenModule } = NativeModules;
  ...
  useEffect(() => {
    // listenBack();//监听 : 两次点击返回按钮退出APP
    // getImage();//
    SplashScreenModule.hide();//关闭启动页
    return () => {
      // removeListenBack();
    }

  }, [])

效果展示

WeChat_20221116202402

详细配置参考

github:https://github.com/QWYZ/studyRN

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值