Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android Exit from full screen mode

I am working in Android. I need to show my activity in Full screen mode, and i did this using following code.

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);

Now its looking like this:- enter image description here

Now I want to exit from this full mode so my activity should show as before. like this:-

enter image description here

I have a button which is used to switch between full mode or normal mode, i will switch mode again and again. Please suggest me how can i do this. Means how can get normal screen from full screen.

Thank you in advance.

like image 510
Pushpendra Kuntal Avatar asked Mar 13 '12 13:03

Pushpendra Kuntal


People also ask

How do I turn off full screen mode?

Using the F11 key on your computer's keyboard will let you both enter and exit full-screen mode in many applications. If you use a laptop, you might need to press Fn + F11 to activate this keyboard shortcut.

How do I exit full screen on Samsung?

From Settings, tap Display, and then tap Full screen apps.

Which key is used to exit from full screen mode?

You can set Google Chrome, Internet Explorer, Microsoft Edge, or Mozilla Firefox to full-screen mode on a computer, hiding the toolbars and address bar, by pressing the F11 key. To change the browser window back to showing the toolbars and address bar, press F11 again.


2 Answers

As per below code, i can hide the TitleBar by your needs,

Button full;
static int vari = 0;

@Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    full = (Button)findViewById(R.id.fullview);
    full.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            if(vari == 0)
            {
                getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
                getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
                vari = 1;
            }else 
            {
                getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
                getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);                 
                vari = 0;
            }

        }
    });
}

Try this code. It helps you lot.

like image 179
Praveenkumar Avatar answered Oct 12 '22 11:10

Praveenkumar


To disable full screen:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
ActivitiesCurrentContentView.requestLayout();

To re-enable full screen:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
ActivitiesCurrentContentView.requestLayout();

I think the key in your case is re-requesting the layout.

like image 38
bbedward Avatar answered Oct 12 '22 12:10

bbedward