Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Toggle Fullscreen mode

Tags:

I need some help toggling fullscreen mode. I have a setting in a preference screen to go fullscreen. In my main activity's onResume I have:

if(mFullscreen == true) {                 getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);                 getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);              } else             {                 getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);                 getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);              } 

But this doesn't seem to work because it needs to be called before setContentView right?

... But Also, I have requestWindowFeature(Window.FEATURE_NO_TITLE); before setContentView and it takes away the title AND status bar... Can anybody offer some help?

---Edit--- Ok, I had a bug that was causing this to not work. So it actually does. Now, I just need to know how to toggle the title bar.

like image 230
bwoogie Avatar asked Oct 07 '11 20:10

bwoogie


People also ask

What is toggle for full screen?

In a browser on a Windows computer, you can enter fullscreen mode by pressing the F11 key. The key or method for entering fullscreen mode may vary in other programs.

How do I toggle full screen without F11?

Hold down the Ctrl key (or the Command key on a Mac) and press the plus or minus keys on the keyboard to zoom in and out, respectively.

How do I toggle full screen on Windows 10?

It can be any webpage you want. Press the F11 key. Now your browser is full screen. If you want to toggle the full-screen mode off, simply press F11 again.

How do I toggle full screen in Chrome?

To go full screen on Google Chrome, click the full screen mode icon in its hamburger menu. You can also enter full screen by pressing "F11" on PC or "Control + Command + F" on Mac. Mac users can also press the "expand window" button to enter or exit full screen in Chrome.


1 Answers

private void setFullscreen(boolean fullscreen) {     WindowManager.LayoutParams attrs = getWindow().getAttributes();     if (fullscreen)     {         attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;     }     else     {         attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;     }     getWindow().setAttributes(attrs); } 
like image 125
cprcrack Avatar answered Sep 27 '22 03:09

cprcrack