android Exit from full screen mode
Asked Answered
C

3

15

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.

Changchangaris answered 13/3, 2012 at 13:1 Comment(1)
Is upvote is needed? I think it won'tBrainless
B
49

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.

Brainless answered 13/3, 2012 at 13:50 Comment(2)
Working fine tested on 8.0Enstatite
window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN) is enough to exist fullscreen modeAstute
L
15

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.

Linzer answered 13/3, 2012 at 13:8 Comment(2)
What is ActivitiesCurrentContentView here? There is no class with that name! @LinzerSaturation
This hides only Status barLach
L
0

From ICS when the Fragment is attached to the Activity, the FULL Screen mode is reseted. The best approach is to add the code

getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); getActivity().findViewById(R.id.root).setSystemUiVisibility(View.STATUS_BAR_HIDDEN);

in the callback onActivityCreated of the fragment(layout id root is the root layout of the Activity).

Like answered 29/11, 2013 at 11:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.