Skip to content

Instantly share code, notes, and snippets.

@mykltronn
Last active June 11, 2019 02:58
Show Gist options
  • Save mykltronn/55da0eb5d7895204ada93be3680b16df to your computer and use it in GitHub Desktop.
Save mykltronn/55da0eb5d7895204ada93be3680b16df to your computer and use it in GitHub Desktop.
Globally disable Android software navigation bar in React Native
package com.myApp;
. . .
// imports
. . .
public class MainActivity extends ReactActivity {
@Override
protected String getMainComponentName() {
return "MyApp";
}
+ @Override
+ public void onWindowFocusChanged(boolean hasFocus) {
+ super.onWindowFocusChanged(hasFocus);
+ if (hasFocus) {
+ hideNavigationBar();
+ }
+ }
. . .
private void hideNavigationBar() {
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| 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
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment