Question

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.

Était-ce utile?

La solution

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);
        }
    }
}

Autres conseils

You can add this close in onResume event.

@Override
    public void onResume() {
        super.onResume();
        getWindow().getDecorView().setSystemUiVisibility(
                View.GONE);
    }
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top