title: How to disable statusbar and navigationbar animation when activating/deactivating full-screen mode in Android
body: <p><strong>Problem</strong></p>
  <p>Activating and Deactivating <a href="https://developer.android.com/training/system-ui/immersive" rel="nofollow noreferrer">(immersive) full-screen mode</a> causes that the statusbar but also navigation bar &quot;fades&quot; 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.</p>
  <p><strong>Running demo</strong></p>
  <p>I implemented a (minimal) demo so that people can test things easily. Everything is available on GitHub:</p>
  <ul>
  <li><a href="https://github.com/sztyler/android-fullscreendemo" rel="nofollow noreferrer">https://github.com/sztyler/android-fullscreendemo</a></li>
  </ul>
  <p>For clarification, I am using <code>setSystemUiVisibility(FLAGS)</code> to activate/deactivate the full screen mode. Further, I am using the following flags:</p>
  <p>Activating full-screen mode:</p>
  <pre><code>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);
  </code></pre>
  <p>Deactivating full-screen mode:</p>
  <pre><code>int visibility = View.SYSTEM_UI_FLAG_VISIBLE;
  mainView.setSystemUiVisibility(visibility);
  </code></pre>
  <p><strong>What I tried</strong></p>
  <p>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.</p>
  <ol>
  <li>Instead of using <code>setSystemUiVisibility</code> (which seems to be recommended) a lot of people recommend to use <code>getWindow().setFlags</code> 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.</li>
  </ol>
  <ul>
  <li><a href="https://stackoverflow.com/questions/9312029/how-to-remove-statusbar-animation-when-changing-to-fullscreen-in-android">how to remove statusbar animation when changing to fullscreen in Android</a></li>
  <li><a href="https://stackoverflow.com/questions/38189152/hide-and-show-statusbar-with-toolbar-at-the-same-time-in-android">Hide and show statusBar with Toolbar at the same time in android</a></li>
  <li><a href="https://stackoverflow.com/questions/48782715/android-disable-and-enable-to-pulling-the-status-bar-programmatically-for-api-1">Android: Disable and enable to pulling the status bar programmatically for API 19</a></li>
  <li><a href="https://stackoverflow.com/questions/27224106/hide-and-show-statusbar-without-any-effect-to-layout-in-android">hide and show statusbar without any effect to layout in android</a></li>
  <li><a href="https://stackoverflow.com/questions/8273186/android-show-hide-status-bar-power-bar">Android: show/hide status bar/power bar</a></li>
  </ul>
  <ol start="2">
  <li>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.</li>
  </ol>
  <ul>
  <li><a href="https://stackoverflow.com/questions/26600263/how-do-i-prevent-the-status-bar-and-navigation-bar-from-animating-during-an-acti">How do I prevent the status bar and navigation bar from animating during an activity scene animation transition?</a></li>
  </ul>
  <ol start="3">
  <li><p>Some people just recommend different flags (just in general to hide the bars) -but the animation stays the same.</p>
  <p><code>View.setSystemUiVisibility(View.STATUS_BAR_HIDDEN);</code></p>
  </li>
  </ol>
  <ul>
  <li><a href="https://stackoverflow.com/questions/4904013/android-ability-to-auto-hide-the-title-status-bars">Android: Ability to Auto-Hide the Title/Status Bars?</a></li>
  </ul>
  <ol start="4">
  <li>Some people highlight that it is possible to override the subsequent animation with <code>overridePendingTransition(0, 0)</code>
  but this does not seem so work in this case.</li>
  </ol>
  <ul>
  <li><a href="https://stackoverflow.com/questions/8792101/is-there-any-way-to-remove-notification-status-bar-but-not-in-oncreate">Is there any way to remove notification/status bar, but not in onCreate?</a></li>
  </ul>
  <p><strong>How the animation can look like</strong></p>
  <p>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)</p>
  <p>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 &quot;flash in&quot;.</p>
  <ul>
  <li><a href="https://i.stack.imgur.com/DEQbX.gif" rel="nofollow noreferrer">Statusbar Animation</a></li>
  <li><a href="https://i.stack.imgur.com/MOWnH.gif" rel="nofollow noreferrer">Navigationbar Animation</a></li>
  </ul>
  <p>Android 5.0 / Samsung / There is a fade in and fade out animation (There is no navigationbar).</p>
  <ul>
  <li><a href="https://i.stack.imgur.com/GAq1X.gif" rel="nofollow noreferrer">Statusbar Animation</a></li>
  </ul>
  <p>(The behavior of the actionbar is as expected.)</p>