3

I am using Inmersive Full Screen mode with Sticky flag modality, the fourth of these four modalities explained here: https://developer.android.com/training/system-ui/immersive.html

I am doing this:

    if( Build.VERSION.SDK_INT >= 19 ){      
        //si es mayor o igual a API 19 kitkat ocultamos las barras UI del sistema
        mainBody.setSystemUiVisibility(
                256 //SYSTEM_UI_FLAG_LAYOUT_STABLE
                | 512 //SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | 1024 //SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | 2 //SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
                | 4 //SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
                | 4096 //SYSTEM_UI_FLAG_IMMERSIVE_STICKY
        );
    }

And in my manifest i have this at Application level:

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

It works fine, but i have a Spinner in my app, and when i touch the spinner, the immersive mode disables!!! :S

How can this be solved?

Thanks

NullPointerException
  • 36,107
  • 79
  • 222
  • 382
  • Finally, @Quinn pasted the link to the solution in this answer to a similar question: https://stackoverflow.com/a/60462764/9738227 – Panicum Mar 05 '20 at 08:37

1 Answers1

1

Same problem here.. See also https://code.google.com/p/android/issues/detail?id=68031

Closest I came to solving it is (in your Activity) adding the full screen flag, and setting full screen again when the activity gets focus after closing the spinner:

private void goFullScreen()
{
  // Only navigation will be shown when opening a spinner
  getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

  getWindow().getDecorView().setSystemUiVisibility(yourFlags);
}


@Override
protected void onResume()
{
  super.onResume();
  goFullScreen();
}


@Override
public void onWindowFocusChanged(boolean hasFocus)
{
  // Go full screen again when a spinner is closed
  if (hasFocus) {
    goFullScreen();
  }
}

Yes, it is a workaround.. I will have a look at extending the Spinner.

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
  • Did you get any further with this? I have managed to get immersive mode to resume but the nav bar appears whilst the spinner is shown. – Leon Oct 22 '15 at 11:43
  • No, unfortunately I couldn't spend more time on it. It was no major requirement for our app, so we just dropped it. – Jasper de Vries Oct 22 '15 at 11:46
  • 1
    I got to a slightly nicer workaround based on this. By calling setSystemUiVisibility in an OnTouchListener bound to my spinner. This way you do not see the system UI come up at all. – Nathan Jul 07 '16 at 14:54
  • 1
    @Nathan, can you add the code please? I tried it, but it doesn't work: when I returned false (in onTouch method) , it made no difference, when I returned true, the spinner stopped working. – mrek May 14 '17 at 08:06