I can only set my Activity to Full Screen in onCreate method (before setContentView)?
Is there any way I can set to full screen outside of onCreate?
Thanks
I can only set my Activity to Full Screen in onCreate method (before setContentView)?
Is there any way I can set to full screen outside of onCreate?
Thanks
Is possible! Adding this code.
// go full screen WindowManager.LayoutParams attrs = mActivity.getWindow().getAttributes(); attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN; mActivity.getWindow().setAttributes(attrs); // go non-full screen WindowManager.LayoutParams attrs = mActivity.getWindow().getAttributes(); attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN); mActivity.getWindow().setAttributes(attrs);
The docs for Window.requestFeature
says:
This must be called before setContentView().
so no, I don't believe there is another way to set to full screen after you call setContentView
.
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
Use this before setting layout .Because you are trying to set your layout into fullscreen. Why you need outside of on create method ? ...
Try this:
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
**requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);**
setContentView(R.layout.activity);
...
}