Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Switching from full screen to not full screen pop/slide

Going from not full screen to full screen with Android works fine. However, upon returning from my full screen activity (a full screen video player), the activity pops in sliding down as the status bar animates down. It seems that the resuming activity is animated in from the full screen mode but with the status bar not there the actual activity is being painted as if it were missing.

I have tried messing with my manifest file specifying themes/styles. I have tried doing this programmatically in onCreate() before the content view is set and various other places in the activity life cycle:

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

It seems that there is no way to keep the status bar from animating down and/or from the content view from first drawing without the status bar there and then adjusting down as it is re-shown.

Anyone have any thoughts on this? I am not sure if there is any way to change this and is just a behavior of Android.

Thanks in advance.

like image 671
mhradek Avatar asked Oct 06 '11 00:10

mhradek


2 Answers

You need a few more flags: FLAG_LAYOUT_IN_SCREEN and FLAG_LAYOUT_NO_LIMITS.

Check out http://nubinewsblog.blogspot.com/2009/11/smooth-full-screen-transition.html.

like image 73
Robert Nekic Avatar answered Sep 19 '22 00:09

Robert Nekic


private void toggleFullscreen(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);
}

Use this it will surely work

like image 36
Rahul Avatar answered Sep 21 '22 00:09

Rahul