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
.
setContentView
a second time outside of onCreate
if you like, so as long as you call it after requesting the full screen feature it's fine. Note that it will invalidate any references to Views you have, so you will need to call findViewByID
again after for each View reference. –
Mundane setContentView
yet in onCreate
and only calling it after where you want to call requestFeature
, but once you call setContentView
the above applies. –
Midlothian 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);
...
}
© 2022 - 2024 — McMap. All rights reserved.