Http://blog.csdn.net/lovehong0306
There are two methods for setting and canceling full screen, which are called two forms instead of two, because the two methods are different in writing and are essentially the same.
Form 1:
// Set full screen
Getwindow (). addflags (windowmanager. layoutparams. flag_fullscreen );
// Cancel full screen
Getwindow (). clearflags (windowmanager. layoutparams. flag_fullscreen );
Form 2:
// Set full screen
Windowmanager. layoutparams ATTR = getwindow (). getattributes ();
ATTR. Flags | = windowmanager. layoutparams. flag_fullscreen;
Getwindow (). setattributes (ATTR );
// Cancel full screen
Windowmanager. layoutparams ATTR = getwindow (). getattributes ();
ATTR. Flags & = (~ Windowmanager. layoutparams. flag_fullscreen );
Getwindow (). setattributes (ATTR );
Change the full screen status to non-full screen to keep the content position unchanged:
Getwindow (). setflags (
Windowmanager. layoutparams. flag_layout_in_screen,
Windowmanager. layoutparams. flag_layout_inset_decor );
Here is a problem:
When this flag is set, the full screen is canceled and some content is blocked by the status bar (ignore the height of the status bar and use the origin in the upper-right corner of the screen to calculate the layout)
Add the code getwindow (). clearflags (windowmanager. layoutparams. flag_layout_in_screen); To solve this problem, but the status bar does not disappear when the full screen is set again.
At present, there are no good solutions to this problem,
If you have any ideas to solve this problem, please feel free to provide it to me.
Http://blog.csdn.net/lovehong0306
Dynamic Setting of full screen, canceling full screen, and switching of full screen to keep content unchanged