Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Full screen + action bar (Immersive)

Currently I am using low profile mode to hide the top black bar and dim the bottom nav bar. I want to use Immersive mode on Android but I'm having issues with the action bar. I would like to do Immersive mode sticky but keep the action bar where it should be. Is there no way to do this?

This is what I have so far and it works except that it hides the action bar as well.

@TargetApi(19)
@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    if (hasFocus) {
        if (android.os.Build.VERSION.SDK_INT >= 19) {
            getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
                View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
                View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
                View.SYSTEM_UI_FLAG_FULLSCREEN |
                View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
        }
    }
}

Any advice would be wonderful. Thank you.

like image 864
Andres S Avatar asked Mar 08 '14 06:03

Andres S


1 Answers

I just tried this code on my nexus 7 (Android 4.4.2) and works fine

@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
        if (hasFocus) {
            decorView
                    .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                            | View.SYSTEM_UI_FLAG_FULLSCREEN
                            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
        }
    }
}
like image 161
benleung Avatar answered Oct 19 '22 23:10

benleung