6

Problem

Activating and Deactivating (immersive) full-screen mode causes that the statusbar but also navigation bar "fades" in and out. The animation seem to differ across different devices and I would like to disable the animation completely. My minimum target SDK is 19; however, I would also be happy with a solution that requires a higher API level. Please see below for further details.

Running demo

I implemented a (minimal) demo so that people can test things easily. Everything is available on GitHub:

For clarification, I am using setSystemUiVisibility(FLAGS) to activate/deactivate the full screen mode. Further, I am using the following flags:

Activating full-screen mode:

int visibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                   | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                   | View.SYSTEM_UI_FLAG_FULLSCREEN
                   | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
mainView.setSystemUiVisibility(visibility);

Deactivating full-screen mode:

int visibility = View.SYSTEM_UI_FLAG_VISIBLE;
mainView.setSystemUiVisibility(visibility);

What I tried

I already tried many different things and did a lot of research. In the following, I want summaries the main approaches which I already tried.

  1. Instead of using setSystemUiVisibility (which seems to be recommended) a lot of people recommend to use getWindow().setFlags to change flags. However, setting the Flags in a different way does not seem to have an effect. I also assume that this is outdated.
  1. It seems to be possible to exclude the status bar and navigation bar from the exit/enter fade transition when switching between activities. However, this does not seem to have any effect on activating/deactivating full-screen mode.
  1. Some people just recommend different flags (just in general to hide the bars) -but the animation stays the same.

    View.setSystemUiVisibility(View.STATUS_BAR_HIDDEN);

  1. Some people highlight that it is possible to override the subsequent animation with overridePendingTransition(0, 0) but this does not seem so work in this case.

How the animation can look like

Just to clarify what I mean. In the following, there are gif animations which show the status/navigation bar animation (Sorry I don't have the permission to embed images)

Android 8.0 / Huawei / There is no fade out animation (both bars just vanish as required but there is a fade in animation). Both statusbar and navigationbar "flash in".

Android 5.0 / Samsung / There is a fade in and fade out animation (There is no navigationbar).

(The behavior of the actionbar is as expected.)

Sztyler
  • 329
  • 3
  • 15
YuTendo
  • 61
  • 3

0 Answers0