John
John

Reputation: 323

How to Hide System Navigation Bar in Tablets?

At my Tablet, it has following bar to control back, home etc. (I don't know the correct name, status bar? control bar? Action bar? or other)

In program, it use following method to have a full screen.

requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.PROGRESS_INDETERMINATE_OFF);

But I don't know why the bar still in here. Because of it, I can't have the correct screen size.

Who can tell me how to remove it?

The Bar

Upvotes: 11

Views: 49738

Answers (9)

Andreu
Andreu

Reputation: 41

public class Utils {

public static void hideNavigations(Activity context) {
    View decorView = context.getWindow().getDecorView();
    decorView.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);
}

}

In your Activity:

@Override
protected void onResume() {
    super.onResume();
    Utils.hideNavigations(this);
}

Upvotes: 4

Sunita
Sunita

Reputation: 1219

Below code worked for me -

You can write it in onCreate() or onResume( if needed)

getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_IMMERSIVE
                            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

Upvotes: 0

emidander
emidander

Reputation: 2413

In Android 4.4 and above you can completely hide the navigation bar and have it remain hidden using a combination of fullscreen and immersion:

@Override
protected void onResume() {
    super.onResume();

    View decorView = getWindow().getDecorView();
    decorView.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);
}

Upvotes: 5

Led Machine
Led Machine

Reputation: 7552

As other people say use the command "pm disable com.android.systemui" in root mode, so the following code execute this command in your android app, just call the following method, your tablet needs to be rooted.

private void hideNavigationBar(){
        try {
            Process process = Runtime.getRuntime().exec("su");
            DataOutputStream os = new DataOutputStream(process.getOutputStream());
            os.writeBytes("pm disable com.android.systemui\n");
            os.flush();
            os.writeBytes("exit\n");
            os.flush();
            process.waitFor();
            //////////////////////////////////////
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

This code hide the navigation bar on the android system, to reappear system bar use "pm enable com.android.systemui" instead of "pm disable com.android.systemui" in the previous code.

Upvotes: 1

richmb
richmb

Reputation: 1595

A very nuclear option is to just delete the SystemUI.apk from /system/app/. But warning this will remove it from the tablet completely. I'm doing this on a tablet i'm using for a front panel kiosk, then i set the tablet to boot into my app.

Upvotes: 3

PiyushMishra
PiyushMishra

Reputation: 5773

You can't hide it but you can simply disable it, except home. Try this link. . Using SYSTEM_UI_FLAG_LOW_PROFILE you can dim your system bar and using onWindowFocusChanged() can take the focus and collapse it.

Upvotes: 0

David Rettenbacher
David Rettenbacher

Reputation: 5120

There seems to be a UNDOCUMENTED flag for this:

yourGreatView.setSystemUiVisibility(8);
  • no black footer ("hidden" system bar)
  • resizes view if keyboard shows up (no overlapped inputs)

Verified on Android 4.1.2 (API 16)
Verified on Android 4.1.1 (API 16)
Verified not working on Android 4.0.4 (API 15)

(all tablets)

Upvotes: 36

Swayam
Swayam

Reputation: 16364

In Tablets running Android 4+, it is not possible to hide the System / Navigation Bar.

From documentation (Controls for system UI visibility section) :

The SYSTEM_UI_FLAG_HIDE_NAVIGATION is a new flag that requests the navigation bar hide completely. Be aware that this works only for the navigation bar used by some handsets (it does not hide the system bar on tablets).

However, you could try to dim the system bar as done sometimes during gaming and video playback.

The SYSTEM_UI_FLAG_LOW_PROFILE flag replaces the STATUS_BAR_HIDDEN flag. When set, this flag enables “low profile" mode for the system bar or navigation bar. Navigation buttons dim and other elements in the system bar also hide. Enabling this is useful for creating more immersive games without distraction for the system navigation buttons.

Upvotes: 13

Ferdau
Ferdau

Reputation: 1558

Since the system bar is used to navigate in android there is not an easy way to achieve this, you can dissable/dim the controls:

View v = findViewById(R.id.view_id);
v.setSystemUiVisibility(View.STATUS_BAR_HIDDEN);

But you can get the size of the screen without the systembar (not sure from what version, I think 3.1)

Method rawW = Display.class.getMethod("getRawWidth");
Method rawH = Display.class.getMethod("getRawHeight");
int width = (Integer)mGetRawW.invoke(dp);
int height = (Integer)mGetRawH.invoke(dp);

If your app has root access there is also a way to achieve it: http://ppareit.github.com/HideBar/

Upvotes: 0

Related Questions