Remove system menu bar from react native android a

2019-07-28 20:47发布

问题:

My problem is simple and I have been unable to find a solution. The menu bar is very annoying in my app and I am hoping that there is a way to remove it.

回答1:

Looking at Hiding the Navigation Bar I found this:

You can hide the navigation bar on Android 4.0 and higher using the SYSTEM_UI_FLAG_HIDE_NAVIGATION flag. This snippet hides both the navigation bar and the status bar:

View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
          | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);

I do not know if that's exactly what you was looking for, but you can test it.



回答2:

I suggest you read more about native modules, it enables you to write native code and access it from JS.

http://facebook.github.io/react-native/docs/native-modules-android.html#content

Also the StatusBar module is very similar to what you want to do here, you can have a look at the source.

https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.java#L110