React Native Bootsplash在Android端出现底部栏,iOS端无此问题
React Native Bootsplash Android端底部栏异常问题
我在项目中使用React Native Bootsplash组件,iOS端启动页运行完全正常,但Android端运行时屏幕底部会出现底部栏,iOS无此现象。
相关代码
MainActivity.kt
package com.packageName import com.facebook.react.ReactActivity import com.facebook.react.ReactActivityDelegate import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled import com.facebook.react.defaults.DefaultReactActivityDelegate import android.os.Bundle import com.zoontek.rnbootsplash.RNBootSplash class MainActivity : ReactActivity() { override fun getMainComponentName(): String = "packageName" override fun createReactActivityDelegate(): ReactActivityDelegate = DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled) override fun onCreate(savedInstanceState: Bundle?) { RNBootSplash.init(this, R.style.BootTheme) // ⬅️ initialize the splash screen super.onCreate(null) // super.onCreate(null) with react-native-screens } }
styles.xml(路径:android -> src -> main -> res -> values -> styles.xml)
<resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar"> <!-- Customize your theme here. --> <item name="android:editTextBackground">@drawable/rn_edit_text_material</item> <item name="android:forceDarkAllowed">false</item> </style> <!-- BootTheme should inherit from Theme.BootSplash or Theme.BootSplash.EdgeToEdge --> <style name="BootTheme" parent="Theme.BootSplash"> <item name="bootSplashBackground">@color/bootsplash_background</item> <item name="bootSplashLogo">@mipmap/bootsplash_logo</item> <item name="postBootSplashTheme">@style/AppTheme</item> </style> </resources>
测试用index.js代码
const Comp = () => { BootSplash.hide({fade: true}); return <View style={{flex: 1, backgroundColor: 'red'}}></View>; }; // AppRegistry.registerComponent(appName, () => App); AppRegistry.registerComponent(appName, () => Comp)
环境配置
- React Native版本:0.74.1
- React Native Bootsplash版本:6.3.1
排查过程
- 移除MainActivity.kt中的
onCreate方法后,底部栏消失,但启动页无法正常工作 - 简化启动页后的组件进行测试,问题依旧存在
- 在物理Android设备上测试,排除模拟器渲染问题,现象不变
- 移除styles.xml中BootTheme下的以下配置后,底部padding位置仍能看到部分BootSplash内容:
<item name="bootSplashBackground">@color/bootsplash_background</item> <item name="bootSplashLogo">@mipmap/bootsplash_logo</item> <item name="postBootSplashTheme">@style/AppTheme</item>
内容的提问来源于stack exchange,提问作者Vanya
相关产品推荐
相关产品推荐

