Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Immersive fullscreen below 4.4

I have an app that I want to run in fullscreen. If i have a device with 4.4 KitKat it is easy to set the SYSTEM_UI_FLAG_IMMERSIVE to make the app go pure fullscreen. However if i have a device with a lower API than 4.4. I have no idea how to make it fullscreen as if it was a KitKat with Immersive support.

I can set the Fullscreen, and hide navigation flags to make the app go fullscreen, but as soon as the screen is clicked, these flags are reset and will now show both navbar and statusbar.

Is there a solution where i can "simulate" the immersive mode on devices with JB and possibly ICS (not necesserily below).

I have a method hideSystemUI which runs when OnSystemUiVisibilityChangeListener triggers which look like this at the moment.

private void hideSystemUI() {
        actionBar.hide();
        isMenuVisible = false;
        if (currentapiVersion >= android.os.Build.VERSION_CODES.KITKAT){
            mDecorView.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);
        }
        else{
            mDecorView.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);
        }
}

What changes do I need to make to make the app go fullscreen and not showing navbar and statusbar on every click, but rather on slide from top or bottom.

like image 580
jdahlgren Avatar asked Feb 08 '14 22:02

jdahlgren


1 Answers

This is as close as you're going to get:

if (Build.VERSION.SDK_INT >= 19) {
    getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
} else {
    if (Build.VERSION.SDK_INT > 10) {
        findViewById(android.R.id.content).setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
    }
}

And don't support devices with an SDK less than 10. Those jokers need to get a modern android anyway.

like image 183
ShellDude Avatar answered Nov 15 '22 14:11

ShellDude