DaleYY
DaleYY

Reputation: 130

How to hide StatusBar in Android 4

How to hide StatusBar in Android 4:

StatusBar in Android 4

Help me, please.

Upvotes: 8

Views: 9219

Answers (4)

BladeLeaf
BladeLeaf

Reputation: 458

I agree with Janusz. You can not get 100% true full screen in Android 4.0.

Use the following to dim the notification bar (aka. status bar, system bar)

getWindow().getDecorView().setSystemUiVisibility
  (View.SYSTEM_UI_FLAG_LOW_PROFILE); 

And use this to hide it

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

And, if I guess right, you are trying to achieve a "kiosk mode". You can get a little help with an app named "surelock". This blocks all the "home" and "back" actions.

Upvotes: 5

Édouard Mercier
Édouard Mercier

Reputation: 495

If you wish a smooth experience without an intermediate "jerked" layout, here is the solution from API level 14.

final Window window = getWindow();
if (isFullScreen == true)
{
  window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
  // This flag will prevent the status bar disappearing animation from jerking the content view
  window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
  window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
}
else
{
  window.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
  window.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
  window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}

Upvotes: 3

Janusz
Janusz

Reputation: 189594

The bar that is shown in the image in your question is called the system bar.

On devices with no hardware buttons the system bar will always be displayed if user input occurs. You can call setSystemUiVisibility with the flags SYSTEM_UI_FLAG_HIDE_NAVIGATION and request the following window feature FLAG_FULLSCREEN via the Window. This should hide the system bar and make your view fullscreen as long as the user does not interact with the screen. If the user touches the screen the system bar will reappear to allow the user to use the home and back software keys.

If you have a view that the user will interact with but you want him not to be distracted by the system bar you can set the SYSTEM_UI_FLAG_LOW_PROFILE flag. This should dim the system bar and make it less distracting.

Upvotes: 6

Unicusand
Unicusand

Reputation: 65

you can hide it. just use following api in OnCreate() method

requestWindowFeature(Window.FEATURE_NO_TITLE);

Upvotes: -3

Related Questions