这是最简单的方法,比使用react-native-splash-screen组件方便许多,效果为启动后出现一张自定义图片,应用加载后会覆盖该图片。
步骤如下
- 打开 android\app\src\main\res\values 下的styles.xml
<resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <!-- Customize your theme here. --> <!-- 加入下面这两行代码,开启启动图 --> <item name="android:windowTranslucentStatus">true</item> <item name="android:windowBackground">@drawable/launch_screen</item> </style> </resources>
- 在 android\app\src\main\res 目录下新建drawable目录,在里面放入一张命名为launch_screen.jpg的图片
- 重启应用,就可以看到添加的启动图啦,是不是很方便呢