1

I use

mContext.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
mContext.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
mContext.getWindow().getDecorView().requestLayout();

to hide the status bar after setContentView. The status bar is hided,but my view does not go to the top.There is a black rectangle
instead of the status bar.

Veger
  • 37,240
  • 11
  • 105
  • 116
s u
  • 19
  • 4

3 Answers3

0

You can use this in the Manifest file of that particular activity. remove above code from java file and put below code in Manifest in the activity

android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
Dinesh Prajapati
  • 9,274
  • 5
  • 30
  • 47
0

here is the solution : just check it out

// hide titlebar of application
    // must be before setting the layout
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    // hide statusbar of Android
    // could also be done later
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.main);
Nipun Gogia
  • 1,846
  • 1
  • 11
  • 17
  • Somewhere I need hide the status bar,but others do not.The code hide everywhere – s u Mar 01 '13 at 09:35
0

For hiding the status bar please add request feture with no title and flag as full screen then add the content view.

Code is

requestWindowFeature(Window.FEATURE_NO_TITLE);
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_test); 

And for only the notification bar

this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Chinmoy Debnath
  • 2,814
  • 16
  • 20