11

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

Mayank Kumar Chaudhari
  • 16,027
  • 10
  • 55
  • 122
John
  • 323
  • 2
  • 4
  • 13

9 Answers9

36

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)

David Rettenbacher
  • 5,088
  • 2
  • 36
  • 45
  • 2
    this must be post in every question about Uisystem on ICS this work fine and is cooler than LOW PROFILE MODE Can't thank you enough for this – Jebik Jun 05 '13 at 12:22
  • strange, i have 2 tablets running 4.2.2. it works on one and not on the other. must be some other settings involved? – steveh Jul 03 '14 at 00:20
  • 3
    Yea, hard to upvote when it doesn't work for most of us. WAAAYYY too many variants of Android, its hardware, .... I hate iPhone, but man, I'm really getting sick of this... – Kevin Jan 23 '15 at 01:10
  • Does not work on android 5.0.1, i am doing it as: `@Override protected void onResume() { super.onResume(); View decorView = getWindow().getDecorView(); decorView.setSystemUiVisibility(8);` – Shajeel Afzal Aug 26 '15 at 17:10
  • 1
    I can confirm it doesn't work on Android 5.0.1, Nexus 6p. – Siniša Oct 17 '15 at 02:36
13

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.

Christopher Perry
  • 38,891
  • 43
  • 145
  • 187
Swayam
  • 16,294
  • 14
  • 64
  • 102
  • Does any method can ignore this system bar to have the correct screen size? – John Sep 26 '12 at 15:46
  • You could try to dim the system bar. – Swayam Sep 26 '12 at 15:49
  • how to dim it? Could you tell me? – John Sep 26 '12 at 16:03
  • I found it. http://stackoverflow.com/questions/5883789/how-do-i-dim-the-system-bar-in-android-3-0-honeycomb – John Sep 26 '12 at 16:06
  • Yeah, it would work if you are using Android versions before ICS. Post Android 4+, the flag needs to be `SYSTEM_UI_FLAG_LOW_PROFILE` , as I have already mentioned in my answer. For Android 4+, use `myView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);` to dim the system bar – Swayam Sep 26 '12 at 16:11
  • oh no! I try the method, but it still in here. But it's style changed dot. e.g. the back and home key are changed to a dot. – John Sep 26 '12 at 16:22
  • " Navigation buttons dim and other elements in the system bar also hide." This is what the documentation says. I guess whatever you are getting is the best thing you could get. I believe the bar would dim if you did not touch the screen for sometime. – Swayam Sep 26 '12 at 16:27
  • I will bravely to face it. Thanks! – John Sep 26 '12 at 16:32
  • No problem. And yeah, please do upvote / accept if the answer was of any help to you. Thanks! Cheers and good luck! :) – Swayam Sep 26 '12 at 16:38
5

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);
}
emidander
  • 2,383
  • 22
  • 29
  • It seems if I remove the first View item in the setSystemUiVisibility I still have my action bar but no status and nav bar. However opening the keyboard brings the bars back. Is there a way to prevent this? – Rand May 25 '15 at 15:53
4
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);
}
Andreu
  • 41
  • 3
3

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.

richmb
  • 1,495
  • 2
  • 15
  • 20
  • I'm running 4.4.4 on a Nexus 7, and SystemUI.apk was in /system/priv-app instead. – TimH - Codidact Dec 06 '14 at 01:05
  • What is the easy way to reach at that path? – Shajeel Afzal Aug 26 '15 at 16:51
  • adb shell "rm /system/app/SystemUI.apk" – richmb Aug 30 '15 at 23:01
  • you should back up the SystemUI.apk file before deleting this incase you need to put in back . adb pull /system/app/SystemUI.apk. This path may be different depending on tablet. use adb shell and explore the file system on your tablet. These operations require root privaleges and for this partition to be mounted as writable. you may need to do "mount -o remount,rw /system" and then rm the SystemUI.apk file. – richmb Aug 30 '15 at 23:07
1

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.

Led Machine
  • 7,122
  • 3
  • 47
  • 49
0

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/

Ferdau
  • 1,524
  • 1
  • 12
  • 21
0

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.

Community
  • 1
  • 1
PiyushMishra
  • 5,743
  • 6
  • 37
  • 57
0

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);
Sunita
  • 1,219
  • 12
  • 16