Immersive mode for devices with navigation bar

Create issue
Issue #96 resolved
Juno Nguyen created an issue

(Virtual) Navigation bar is getting more and more common among Android devices (Nexus, HTC, Sony Xperia, etc), and while not all apps need immersive mode (in which status bar and navigation bar is hidden), I find it a major experience enhancement for the majority of mobile games. I personally believe that this should be an mandatory setting for this for all game engines that build to Android, and this is no exception.

As a simple implementation (on 0.9.1b), I have been able to do this by adding this block to onCreate() function of GameActivity:

    public void onWindowFocusChanged(boolean hasFocus) {
      super.onWindowFocusChanged(hasFocus);
      if (hasFocus) {
          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);
      }
    }

There should also be some sort of setting function. Ideally, it would be in conf.lua as this should remain constant and unchanged while the game is running, but I'm not sure if this port is utilizing this file?

Comments (3)

  1. Martin Felis repo owner

    Nice suggestion! Using immersion mode is now default as of 535a8256.

    I might add an option to conf.lua which only uses it when fullscreen is requested.

  2. Alex Szpakowski

    In the iOS port of LÖVE, the status bar is hidden in fullscreen or if borderless mode is used (in love.conf or love.window.setMode.) borderless mode defaults to true in love.conf in the iOS port (whereas on desktops it's false by default.)

  3. Martin Felis repo owner

    Ah, thanks for the info. Will adhere to that convention when tackling the love.conf file.

  4. Log in to comment