所以我试图全屏运行我的React Native Android应用程序,这意味着没有状态栏,底部没有导航栏 . 我已将此添加到我的MainActivity中:

protected void goFullScreen()
{
    getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_FULLSCREEN
            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);

}

@Override
protected void onStart()
{
    this.goFullScreen();
    super.onStart();
}

SYSTEM_UI_FLAG_IMMERSIVE_STICKY基本上是这样的,所以你可以从屏幕的顶部或底部边缘滑动以使它们上升,然后它们会在一段时间后再次消失 .

这很好用 until 我打开任何模态(使用react-native-modal包,但它's based on the regular React Native Modal component). At that point both the status bar and the navigation bar appear. I' m不是Android开发者,但我认为它基本上创建了一个全新的窗口/活动/无论是为对话调用,这都不是't inherit the flags set for the main activity. Thinking it'这里发生这种情况:

/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java

它创建一个新的app.android.Dialog .

无论如何,我已经能够通过更改styles.xml(see here)中的主题来摆脱状态栏:

<style name="AppTheme" parent="Theme.ReactNative.AppCompat.Light.NoActionBar.FullScreen">
    <!-- Customize your theme here. -->
</style>

但是,导航栏仍然存在,它在我的应用程序UI的顶部打开,在关闭对话框后甚至不会消失,所以它完全搞砸了 .

任何人都知道我怎么能摆脱它?最好不修补/重建RN?