Navigation bar cannot be locked in fullScreen mode in Android

edited May 2016 in Android Mode

I have updated to latest processing. I know i have to use the fullscreen option to avoid white screen problem. My code works properly in phones which has a hardware navigation bar like this

But when i run it in phones having virtual navigation bar like

The navigation bar hides automatically and pop up again when screen is touched. This makes the app to behave abnormally as the screen width and height is changed each time the navigation bar appears and disappears.

So pls help me to lock the navigation bar permanently in its place.

Answers

  • @aswinth_raj===

    you cannot hide the navigation bar definetely as the user could want to see it at any moment; you can only hide it till the user swipe the screen using for that a flag at start in onCreate() && onResume(); yet you can do that the navigation bar or the status bar does not affect the size of your layout setting other flags. Which flags you can use depends of your minSdk: as for an example SYSTEM_UI_FLAG_IMMERSIVE_STICKY | SYSTEM_UI_FLAG_LAYOUT_STABLE cannot be used before16. Note that the immersive mode sticky is very simple to use (more than immersive) but that the duration of the navigation bar visible cannot be handled.

  • its okay if i cant hide the navigation bar. How can i make it locked. Please help me with the code. I am a newbie.

  • edited May 2016 Answer ✓

    @Aswinth_Raj==== simple code example

        import android.view.View;
        import android.app.Activity;
    
        Activity act;
    
        private static final int SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN = 0x00000400;
          private static final int SYSTEM_UI_FLAG_IMMERSIVE_STICKY = 0x00001000;
          private static final int SYSTEM_UI_FLAG_LAYOUT_STABLE = 0x00000100;
    
          private static final int SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION = 0x00000002;
    
    
    
    
        public void setup(){
          size(600,1000);
    
          textSize(36);
          fill(255,0,0);
          text("NAVIGATION BAR HIDDEN", 60,400);
          text("&& StatusBar HIDDEN", 60, 450);
          text("till the user swipe on them",60,500);
    
        }
    
    
    
        public void draw(){
    
          ////
    
        }
    
        public void onResume(){
            super.onResume();
             act = this.getActivity();
            View decorView = act.getWindow().getDecorView();
            // Hide both the navigation bar and the status bar.
    
            int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                       | SYSTEM_UI_FLAG_IMMERSIVE_STICKY |         SYSTEM_UI_FLAG_LAYOUT_STABLE ;
                  decorView.setSystemUiVisibility(uiOptions);
    
        };
    
  • edited May 2016

    Thanks a lot for your effort!!

    But I still have the same problem!!

    I added void settings() { fullScreen(); }

    to the program to run it in full screen but now the same problem occurs, the navigation bar does not stick to the bottom. It slides down and reappears on touching the screen(Touched exactly at the center of screen dint swipe).

    I know it would work well if I remove the fullScreen(); and give a std size(x,y). But that is not recommended, because i have to run it in other devices also.

    Please suggest me a way to work in fullscreen() with all time visible navigation bar (LOCKED Permanently) :)] :)

  • Have you tried the new android mode? The nav bar will appear with a swipe at bottom of screen, but then disappear after a few seconds, allowing you to have fullscreen for your app

  • Do you mean the latest update ? No I am currently working with 3.0.2.Will the update solve the problem? Anyway will try it and get back guys!!

  • edited May 2016

    3.1 is the latest processing and RC4 is the new android mode ... you should have an 'update' button showing at bottom of the IDE

  • @Aswinth_Raj=== -you cannot lock the action bar permanently:: that is forbidden by android -you can hide the action bar (&& status bar) according to flags - depending of the choosen flags they will appear when the user swipe the screen anywhere or only when he swipes at the top -depending of the choosen flags they appear for a short or more long time -depending of the flags you can define this time -have you tried my code touching or swiping the middle of the screen?

  • @akenaton , Yes i tried your code and touched at the middle of the screen but unfortunately the navigation bar peaks in. Its okay if it comes while swiping at the bottom of the screen. But now it interrupts every time i touch the screen anywhere

  • @Aswinth_Raj=== i tested again with another phone= sorry, it runs as it is

  • any idea how to solve it?

  • Aswinth_Raj===

    A) dont modify the code i have send b) what is the os version on your phone (some flags are only for lollipop && marshmallow)??? c) what min sdk???

  • Yes akenaton, the problem was with my phone the code works like a charm.

    Thank you!

  • Just in case If anyone has the same problem and requires a temp solution.

    Replace 'void settings() { fullScreen(); }'

    By 'void setup() { size(displayWidth,displayHeight); }'

Sign In or Register to comment.