Can I only set the My Activity action to Full Screen in the onCreate method (before setContentView)?
Is there a way I can set full screen outside of onCreate?
thanks
Maybe! 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 read:
Window.requestFeature
This must be called before setContentView ().
so no, I do not believe that there is another way to set the full screen after calling setContentView .
setContentView
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Use this before setting up your layout. Because you are trying to customize the layout in full screen. Why do you need an external create method? ...
Try the following:
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); ... }