# Hide navigation bar?

**URL:** <https://discourse.processing.org/t/hide-navigation-bar/43400>\
**Category:** Processing for Android\
**Created:** [December 5, 2023, 10:14pm UTC](https://discourse.processing.org/t/hide-navigation-bar/43400 "2023-12-05T22:14:59Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![dtmr](https://avatars.discourse-cdn.com/v4/letter/d/4da419/32.png) [@dtmr](https://discourse.processing.org/u/dtmr)\
**Post date:** [December 5, 2023, 10:14pm UTC](https://discourse.processing.org/t/hide-navigation-bar/43400/1 "2023-12-05T22:14:59Z")

</div>

Is there a way? For Android 4 upwards (= Android without navigation by gestures)?

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [December 6, 2023, 7:11pm UTC](https://discourse.processing.org/t/hide-navigation-bar/43400/2 "2023-12-06T19:11:42Z")

</div>

Not sure what code you are running, but there is no action bar by default.

 ![mfest](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/2/c/2c6ad88b6785c9793f4055fa27fc1172d9bf08b8.png)

---

<div class="post-metadata">

**Author:** ![dtmr](https://avatars.discourse-cdn.com/v4/letter/d/4da419/32.png) [@dtmr](https://discourse.processing.org/u/dtmr)\
**Post date:** [December 7, 2023, 10:33am UTC](https://discourse.processing.org/t/hide-navigation-bar/43400/3 "2023-12-07T10:33:03Z")

</div>

The question was about the navigation bar.

![navigation](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/c/8/c8228926ef1b5d090feb968ccdca478eda1c529e.png)

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [December 7, 2023, 11:57am UTC](https://discourse.processing.org/t/hide-navigation-bar/43400/4 "2023-12-07T11:57:07Z")

</div>

Hi

Some information

> **[Processing 2.x and 3.x Forum](https://forum.processing.org/two/discussion/6871/hiding-the-navigation-bar-in-android.html)**
>
> Processing is an electronic sketchbook, a language and a worldwide community. This is its forum.

> **[Hide the navigation bar  |  Android Developers](https://developer.android.com/training/system-ui/navigation#java)**

> <https://stackoverflow.com/questions/73481995/completely-hiding-navigation-bar-not-only-buttons-in-android>

> **[Android: Removing the Navigation Bar in Android 11 using Java](https://copyprogramming.com/howto/java-how-to-remove-navigation-bar-android-11)**
>
> How do I hide the status bar in my Android 11 app?, Remove status bar and Navigation Bar in AOSP, How to hide navigation bar in Android App Code, Permanently hide Navigation Bar in an activity

---

<div class="post-metadata">

**Author:** ![dtmr](https://avatars.discourse-cdn.com/v4/letter/d/4da419/32.png) [@dtmr](https://discourse.processing.org/u/dtmr)\
**Post date:** [December 7, 2023, 12:22pm UTC](https://discourse.processing.org/t/hide-navigation-bar/43400/5 "2023-12-07T12:22:55Z")

</div>

I’ve already been down the Google road. I couldn’t get anything to work. I didn’t bother to try the solutions for higher Android versions since I need one for Android 4 and upwards. Does nobody have working Processing code?

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [December 7, 2023, 2:49pm UTC](https://discourse.processing.org/t/hide-navigation-bar/43400/6 "2023-12-07T14:49:37Z")

</div>

Are you able to run the following:

```auto
void setup() {
  fullScreen();
  background(209);
  fill(0, 255, 0);
  rect(200,200,400,400);
}

void draw() {  
}

```

There are no bars on my Android system.

 ![bars](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/7/f/7f6f762e49ff53f5b522c715b32e45f2b17f70e7.png)

Are you running your code in the Processing IDE or some other editor?

---

<div class="post-metadata">

**Author:** ![dtmr](https://avatars.discourse-cdn.com/v4/letter/d/4da419/32.png) [@dtmr](https://discourse.processing.org/u/dtmr)\
**Post date:** [December 7, 2023, 5:37pm UTC](https://discourse.processing.org/t/hide-navigation-bar/43400/7 "2023-12-07T17:37:23Z")

</div>

Thanks, that was very helpful. Your test app has no navigation bar but mine has. It turns out I must have fullScreen() in the settings() function, if there is a settings() function, and I can not even have an if condition around it, like:

```auto
if (TARGET_ANDROID)
{
    fullScreen();
}

```

One problem remains: When calling up the keyboard, the navbar comes back but won’t disappear after the keyboard has been closed.

---

<div class="post-metadata">

**Author:** ![shedMusic](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/shedmusic/32/601_2.png) [@shedMusic](https://discourse.processing.org/u/shedMusic)\
**Post date:** [December 8, 2023, 9:36pm UTC](https://discourse.processing.org/t/hide-navigation-bar/43400/8 "2023-12-08T21:36:23Z")

</div>

You might have to call hideSystemUI()

Have a look at the code near the end of this thread

> [@Immersive mode broken?](https://discourse.processing.org/t/immersive-mode-broken/7694):
>
> Hi Just upgrade my phone from 7.1 to 8.1 and seem to have lost immersive mode … bottom menu bar is permanently visible, I recall that immersive was set to be default behaviour for Android mode a year or so ago … or maybe even longer than that… but does this need updating for the latest android versions? Or… can some one provide a code snippet that would let me set immersive mode myself? Many thanks Mark EDIT: Just managed to get it working in Android Studio by pasting the code below into …

---

<div class="post-metadata">

**Author:** ![dtmr](https://avatars.discourse-cdn.com/v4/letter/d/4da419/32.png) [@dtmr](https://discourse.processing.org/u/dtmr)\
**Post date:** [December 9, 2023, 2:08pm UTC](https://discourse.processing.org/t/hide-navigation-bar/43400/9 "2023-12-09T14:08:17Z")

</div>

Bugs observed since adding fullScreen():

- On my Android 9 SamsungS8+ phone, fullScreen() makes the navigation buttons disappear but not the bar behind them. The bar is always displayed and obscures a part of my app.

- On my Android 6 Huawei M10 8.0 tablet, fullScreen() makes the navigation buttons/bar disappear but only until the soft keyboard is displayed. Then they come back and stay for good, even after the keyboard is closed. Additionaly, every 1-2 minute, I see a flicker on the screen. I recorded that with a camera to discover more and it turns out that for a fraction of a second, the screen content of my app is shifted down by ~1cm?!

- On my OS Galaxy Tab 10 with Lineage OS 17 (= Android 10), fullScreen() has no issues.

So unfortunately, this is not a workable solution. I use Processing 3 and Android mode 4.1.1 but I tried Processing 4.3 and the latest Android mode, too, without a better result.

> You might have to call hideSystemUI()

My installation does not seem to know the constants (only tried this with Processing 3). I defined them myself but it seems hideSystemUI() never gets called after closing the keyboard with the back button.

```auto
import android.view.View;

final int SYSTEM_UI_FLAG_IMMERSIVE = 2048 ;
final int SYSTEM_UI_FLAG_LAYOUT_STABLE = 256;
final int SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION = 512 ;
final int SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN = 1024 ;
final int SYSTEM_UI_FLAG_HIDE_NAVIGATION = 2;
final int SYSTEM_UI_FLAG_FULLSCREEN = 4;

// for Android, comment out under Java

public void
onWindowFocusChanged(boolean hasFocus)
{
    this.getActivity().onWindowFocusChanged(hasFocus);
    
    if (hasFocus)
    
        hideSystemUI();
}

private void
hideSystemUI()
{
    // Enables regular immersive mode. For "lean back" mode, remove SYSTEM_UI_FLAG_IMMERSIVE. Or for "sticky immersive," replace it with SYSTEM_UI_FLAG_IMMERSIVE_STICKY
    
    View decorView = getActivity().getWindow().getDecorView();

    decorView.setSystemUiVisibility
    (
            SYSTEM_UI_FLAG_IMMERSIVE
            // Set the content to appear under the system bars so that the content doesn't resize when the system bars hide and show.
            | SYSTEM_UI_FLAG_LAYOUT_STABLE
            | SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            // Hide the nav bar and status bar
            | SYSTEM_UI_FLAG_HIDE_NAVIGATION
            | SYSTEM_UI_FLAG_FULLSCREEN
    );
    
    println("called");
}

```

---

<div class="post-metadata">

**Author:** ![shedMusic](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/shedmusic/32/601_2.png) [@shedMusic](https://discourse.processing.org/u/shedMusic)\
**Post date:** [December 10, 2023, 10:13am UTC](https://discourse.processing.org/t/hide-navigation-bar/43400/10 "2023-12-10T10:13:02Z")

</div>

@dtmr

I had forgotten about this, but that code is old … deprecated a few years back … this link explains …

- [kotlin - android.view.View.systemUiVisibility deprecated. What is the replacement? - Stack Overflow](https://stackoverflow.com/questions/62577645/android-view-view-systemuivisibility-deprecated-what-is-the-replacement)

This code seems to work …

```auto

import android.view.*;
import android.os.Build;

void settings() {
  fullScreen() ;
}

void setup() {
}

void draw() {
}

void mousePressed() {
  openKeyboard() ;
}

public void
  onWindowFocusChanged(boolean hasFocus)
{
  getActivity().onWindowFocusChanged(hasFocus);
  if (hasFocus)
    hideSystemUI();
}

private void
  hideSystemUI()
{
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { //api 30 & higher
    final WindowInsetsController controller = getWindow().getInsetsController();
    if (controller != null)
      controller.hide(WindowInsets.Type.statusBars());
  } else {
    //use old method ?
    //View decorView = getWindow().getDecorView();
    //decorView.setSystemUiVisibility(
    // View.SYSTEM_UI_FLAG_IMMERSIVE
    // // Set the content to appear under the system bars so that the
    // // content doesn't resize when the system bars hide and show.
    // | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
    // | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
    // | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
    // // Hide the nav bar and status bar
    // | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
    // | View.SYSTEM_UI_FLAG_FULLSCREEN);
  }
}

```

---

<div class="post-metadata">

**Author:** ![dtmr](https://avatars.discourse-cdn.com/v4/letter/d/4da419/32.png) [@dtmr](https://discourse.processing.org/u/dtmr)\
**Post date:** [December 11, 2023, 1:18am UTC](https://discourse.processing.org/t/hide-navigation-bar/43400/11 "2023-12-11T01:18:14Z")

</div>

> depreceated

Just depreceated or not working anymore? I was looking for a solution for Android 4 and upwards and I’m using an older processing (3.4 from 2018) and an older Android mode (4.1.l) from that time.

- I have SDK for API Level 28 (Android 9.0). I think the SDK was installed via Android Studio (I don’t remember how I installed it and why exactly API level 28). Is that why I don’t have View.SYSTEM\_UI\_FLAG\_LAYOUT\_HIDE\_NAVIGATION etc.? Does Google remove depreceated symbols? Compile error: “The primitive type int of View does not have a field SYSTEM\_UI\_FLAG\_LAYOUT\_HIDE\_NAVIGATION”

- Why does it appear as if onWindowFocusChanged() is never called?

```auto
public void
onWindowFocusChanged(boolean hasFocus)
{
    getActivity().onWindowFocusChanged(hasFocus);

    println("called");
}

```

I never see “called” in the console. If I use surfaceWindowFocusChanged() instead of onWindowFocusChanged(), I get calls but not in the context of showing/hiding the keyboard, only upon start and upon exit.

---

<div class="post-metadata">

**Author:** ![shedMusic](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/shedmusic/32/601_2.png) [@shedMusic](https://discourse.processing.org/u/shedMusic)\
**Post date:** [December 11, 2023, 5:46pm UTC](https://discourse.processing.org/t/hide-navigation-bar/43400/12 "2023-12-11T17:46:17Z")

</div>

@dtmr

I don’t know the answers … I just post code that I have been able to use, although this is using the processing library in Android Studio. When I try with Processing I get the same as you. I suspect that Processing’s Android Mode isn’t using some recent updates & requirements related to this. Perhaps raise a GitHub issue asking for fixes to this? I will play a bit more and post if I find anything.

---

<div class="post-metadata">

**Author:** ![Mauro](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@Mauro](https://discourse.processing.org/u/Mauro)\
**Post date:** [April 22, 2024, 8:59am UTC](https://discourse.processing.org/t/hide-navigation-bar/43400/13 "2024-04-22T08:59:24Z")

</div>

Hello shedMusic.  
Many thanks for your suggestion. On my redmi 13 the code works fine!!!

Mauro

---

<div class="post-metadata">

**Author:** ![shedMusic](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/shedmusic/32/601_2.png) [@shedMusic](https://discourse.processing.org/u/shedMusic)\
**Post date:** [April 22, 2024, 9:36am UTC](https://discourse.processing.org/t/hide-navigation-bar/43400/14 "2024-04-22T09:36:47Z")

</div>

That’s great to hear … 👍
