Immersive fullscreen below 4.4
Asked Answered
S

4

19

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.

Schellens answered 8/2, 2014 at 22:4 Comment(3)
Why do you think Google would add specific flags for a immersive mode if it was possible with the existing flags?Bridewell
Well, of course they added the flag becaus no flags could solve that problem. How do apps targeting <4.3 solve fullscreen? I could live with navbar visible, but i would like to show statusbar+actionbar on slidedown. Is that possible at all or do I have to rethink? @BridewellSchellens
@Schellens did you find solution of it ?Execration
T
3

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.

Tolu answered 17/1, 2016 at 19:3 Comment(2)
It is not productive to make rude comments about users using old API version for whatever reason.Schoenberg
I thought this was a technical forum, not a social one. Seriously, SDK 10 is Gingerbread. Take into account the .2% Froyo distribution and we're talking 3.2% of all devices (developer.android.com/about/dashboards/index.html).Tolu
D
1

I had faced the same situation and after some research i figured out it is not possible below 4.4 because of security issues, and so old APIs wont support hiding navigation bar the way you want. Even though from API 4.1 your use of SYSTEM_UI_FLAG_LAYOUT_STABLE flag your layout won't resize and it will inflate behind navigation bar, but you need to make sure none of your important UI components are covered by it.

https://developer.android.com/training/system-ui/immersive.html Hope this helps..:)

Dressler answered 17/12, 2014 at 11:55 Comment(0)
E
0

just copy past below code into value/style.xml.

<resources>


<style name="AppBaseTheme" parent="Theme.AppCompat.Light">

</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>

</style>

Eldoria answered 19/12, 2014 at 10:15 Comment(0)
T
-4

There are two method for immersive mode
To make it remain immersive do change thid line

View.SYSTEM_UI_FLAG_IMMERSIVE

By this line-

View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
Treatment answered 27/8, 2014 at 2:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.