Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide status bar android

How to hide status bar android 4.1.2 ? i want solution to hide the status bar on version 4.1.2

i want to hide status bar on my application

LinearLayout layout = (LinearLayout)findViewById(R.id.layout);    
layout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

this code not work on version 4.1.2

like image 685
Mohammad Alkhdour Avatar asked Nov 11 '13 10:11

Mohammad Alkhdour


People also ask

How do I unhide the status bar on Android?

If you want to bring the Notification Bar back, open Fullscreen: The One Immersive Mode again and tap "Hide Nothing." You can also tap the option next to "Fullscreen" to hide your Notification Bar and your Navigation Bar.


3 Answers

Since Jellybean (4.1) there is a new method that doesn't rely on the WindowManager. Instead use setSystemUiVisibility off of the Window, this gives you more granular control over the system bars than using WindowManager flags. Here is a full example:

if (Build.VERSION.SDK_INT < 16) { //ye olde method
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else { // Jellybean and up, new hotness
    View decorView = getWindow().getDecorView();
    // Hide the status bar.
    int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
    decorView.setSystemUiVisibility(uiOptions);
    // Remember that you should never show the action bar if the
    // status bar is hidden, so hide that too if necessary.
    ActionBar actionBar = getActionBar();
    if(actionBar != null) {
         actionBar.hide();
    }
}
like image 182
Pete Avatar answered Oct 16 '22 09:10

Pete


Add this to your manifest file under the activity tag in which you want to hide status bar

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

and you are done :)

like image 12
Jeffy Lazar Avatar answered Oct 16 '22 09:10

Jeffy Lazar


add these lines in oncreate() method

     requestWindowFeature(Window.FEATURE_NO_TITLE);// hide statusbar of Android
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    WindowManager.LayoutParams.FLAG_FULLSCREEN);
like image 8
Rajiv yadav Avatar answered Oct 16 '22 11:10

Rajiv yadav