Android tablet navigation bar won't hide
Asked Answered
D

4

2

I'm trying to hide the navigation bar, using methods I've found described on the internet.

I have a simple layout which shows a WebView:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:id="@+id/layout" >

    <WebView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/webview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />

</RelativeLayout>

The code that I'm using at app startup is:

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
    web.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
    layout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

But this doesn't hide the navigation bar.

I've added...

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

... to my activity too.

How can I achieve this?

Dunston answered 9/10, 2012 at 16:43 Comment(1)
Hi, I'm still having problems with this I get a gap at the bottom of the screen for devices such as the Nexus 7 & Nexus 10.Push
F
4

You cannot permanently hide the system bar on a tablet.

SYSTEM_UI_FLAG_HIDE_NAVIGATION on Android 4.1 and higher will hide the system bar, but it will reappear as soon as the user does anything.

Freefloating answered 9/10, 2012 at 17:40 Comment(1)
Yes its doing the same as u said. But I want to finish the activity on userInteraction method . But its not functioning properly its finishing my activity after two clicks on the activitySlavin
S
8

you can hide the navigationbar,try this

public void FullScreencall() {
    if(Build.VERSION.SDK_INT < 19) //19 or above api
        View v = this.getWindow().getDecorView();
        v.setSystemUiVisibility(View.GONE);
    } else {
            //for lower api versions.
        View decorView = getWindow().getDecorView(); 
        int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        decorView.setSystemUiVisibility(uiOptions);
    }
}
Shotton answered 6/1, 2015 at 18:25 Comment(2)
Shouldn't it be if(Build.VERSION.SDK_INT > 19) //19 or above api? Notice the bigger-than sign.Critic
It worked for me in order to hide the task bar on Android 4..1 sdk 16.. Thanks.Espagnole
F
4

You cannot permanently hide the system bar on a tablet.

SYSTEM_UI_FLAG_HIDE_NAVIGATION on Android 4.1 and higher will hide the system bar, but it will reappear as soon as the user does anything.

Freefloating answered 9/10, 2012 at 17:40 Comment(1)
Yes its doing the same as u said. But I want to finish the activity on userInteraction method . But its not functioning properly its finishing my activity after two clicks on the activitySlavin
P
0

You can not hide the navigation bar within the given framework. However, there is a work around if rooting the device is an option for you:

  1. Root device

  2. Install and run Busybox

  3. Install HideBar

In HideBar there is an option to run in 'Kiosk' mode, in which there is no way to re-display the navigation bar. Needless to say, you really need to be careful with this.


Poikilothermic answered 17/11, 2012 at 15:5 Comment(1)
@JohnyTex not sure, try: bit.ly/1CLKCf9 This is pretty old now, I don't this answer is relevant any moreEvetta
I
0

May be this helps:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getWindow().setUiOptions(//
    View.SYSTEM_UI_FLAG_FULLSCREEN|//
    View.SYSTEM_UI_FLAG_IMMERSIVE|//
    View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    setContentView(R.layout.main);

    findViewById(R.id.main).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            v.setSystemUiVisibility(//
                View.SYSTEM_UI_FLAG_FULLSCREEN|//
                View.SYSTEM_UI_FLAG_IMMERSIVE|//
                View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
        }
    });
}
Irrelative answered 21/2, 2020 at 13:23 Comment(1)
While this code snippet may solve the question, including an explanation really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. Please also try not to crowd your code with explanatory comments, this reduces the readability of both the code and the explanations!Phonograph

© 2022 - 2024 — McMap. All rights reserved.