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
As onCreate() of an Activity is called only once, this is the point where most initialization should go: calling setContentView(int) to inflate the activity's UI, using findViewById to programmatically interact with widgets in the UI, calling managedQuery(android.
OnCreate is only called once.
onCreate is not private because you do want to subclass an Activity and then use the super Activity onCreate method for the subclass. Actually every Activity you design extends android. app. Activity, so if onCreate was private in that super class, then you wouldn't be able to call onCreate at all.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With