2

Few words for background: Application will be used in exhibition. It should hide home, back, appswitcher buttons and notification bar to prevent user to go settings etc.

Device: Samsung GT-N8000 Android 4.1.2 enter image description here

I have tried to hide them by SYSTEM_UI_FLAG_HIDE_NAVIGATION.

AndroidManifest.xml

android:theme="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen"

MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    View decorView = getWindow().getDecorView();
    int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_FULLSCREEN;
    decorView.setSystemUiVisibility(uiOptions);

    setContentView(R.layout.activity_main);
}

Applicaiton is hiding them when it starts. Everything is fine. But when I make touch on screen, buttons and notificaiton bar is coming out to the bottom of screen.

UPDATE: TRIED TO SOLVE THIS BY onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent event) {
    // TODO Auto-generated method stub
    View decorView = getWindow().getDecorView();
    int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_FULLSCREEN;
    decorView.setSystemUiVisibility(uiOptions);
    return true;
}

Result: Touch->Navigation is opening, Touch->Navigation is hiding :( How to hide buttons and notification bar totally(forever)?

Joe Rakhimov
  • 4,713
  • 9
  • 51
  • 109

1 Answers1

0

You need to use the Immersive mode. See the documentation here : Android Documentation

You need to add this function :

private void hideSystemUI() {
// Set the IMMERSIVE flag.
// Set the content to appear under the system bars so that the content
// doesn't resize when the system bars hide and show.
mDecorView.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 // hide nav bar
        | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
        | View.SYSTEM_UI_FLAG_IMMERSIVE);

}

AlonsoFloo
  • 505
  • 3
  • 10