0

I need to completely remove the actionbarr and navigationbar from my app. So I stay in fullscreen without the possibility to swipe so I get the navigationbar back.

I have now this code in my onreate method which makes it go away but as soon as you swipe the navigation bar will appear again. How can I avoid this?

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);
acroscene
  • 845
  • 4
  • 16
  • 45

1 Answers1

0
  • On your activity override onBackPressed() to prevent activity from going back when back button is pressed. By default it runs finish() method if there is no backStack to run through.

  • On your App theme for the activity, make sure it's a theme that has NoActionBar on it that way it won't have one unless you put one into layout.

style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"

Chris
  • 1,539
  • 13
  • 25
  • Thanks. But how can I avoid the navigation bar to appear when dragging? Theme.AppCompat.Light.NoActionBar doesnt make it go away for ever. Overriding onBackPressed() works to prevent going back to work. But still the other two icons, the drawer and the square works in the navigation bar. I want to completely remove them and keep them away – acroscene Oct 15 '19 at 21:17