title: Android Screen Blinking on show/hide System Bars
body: <h2>The Problem</h2>
  
  <p>I want to show the System Bars when the user scrolls an RecyclerView upwards and hide the System Bars when the user scrolls down. However with my Approach it works, but the content strangly moves and blinks during the show/hide process. U uploaded a Video for the behaviour here: <a href="https://drive.google.com/open?id=0B_b9EpRt-zyHVW54dkQzcXdUTXM" rel="noreferrer">https://drive.google.com/open?id=0B_b9EpRt-zyHVW54dkQzcXdUTXM</a> </p>
  
  <h2>My Approach</h2>
  
  <p>Basically I have this two methods:</p>
  
  <pre><code>   private void hideSystemUI() {
          getActivity().getWindow().getDecorView().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 // hide nav bar
                          | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
                          | View.SYSTEM_UI_FLAG_IMMERSIVE);
  
      }
  
  
      private void showSystemUI() {
          getActivity().getWindow().getDecorView().setSystemUiVisibility(
                  View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                          | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                          | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
      }
  </code></pre>
  
  <p>And i set this onScrollListener to the RecyclerView to hide and show the Status bars depending on the scroll: </p>
  
  <pre><code>   mFragmentListBinding.fragListRvMovies.addOnScrollListener(new RecyclerView.OnScrollListener() {
                  @Override
                  public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                      super.onScrolled(recyclerView, dx, dy);
  
                      if (dy &gt; 5) {
                          //   hideSystemUI();
                          //     SystemUIHelper.hide(getActivity());
                          hideSystemUI();
  
                      } else if (dy &lt; -5) {
                          showSystemUI();
                          //    showSystemUI();
                          //       SystemUIHelper.show(getActivity());
                      }
                      if (pageToDownload &lt; TOTAL_PAGES &amp;&amp; layoutManager.findLastVisibleItemPosition() == adapter.movieList.size() - 1 &amp;&amp; !isLoadingLocked &amp;&amp; !isLoading) {
                          downloadMoviesList();
                      }
  
  
                  }
              });
  </code></pre>
  
  <p>And this is the layout: </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;layout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"&gt;
  
      &lt;android.support.v4.widget.DrawerLayout
          android:id="@+id/frag_drawer_layout"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
  
          &lt;android.support.design.widget.CoordinatorLayout
              android:id="@+id/frag_drawer_coordinator"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:fitsSystemWindows="false"&gt;
  
  
              &lt;android.support.design.widget.AppBarLayout
                  android:id="@+id/frag_drawer_appbar"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:theme="@style/AppTheme.AppBarOverlay"
                  android:transitionGroup="false"
                  tools:targetApi="lollipop"&gt;
  
                  &lt;android.support.v7.widget.Toolbar
                      android:id="@+id/frag_drawer_tb"
                      android:layout_width="match_parent"
                      android:layout_height="?attr/actionBarSize"
  
                      android:background="?attr/colorPrimary"
                      app:layout_scrollFlags="scroll|enterAlways"
                      app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                      app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /&gt;
  
              &lt;/android.support.design.widget.AppBarLayout&gt;
  
              &lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
                  android:id="@+id/frag_drawer_content"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:fitsSystemWindows="false"
                  app:layout_behavior="@string/appbar_scrolling_view_behavior" /&gt;
  
              &lt;android.support.design.widget.FloatingActionButton
                  android:id="@+id/frag_drawer_fab_add"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_gravity="end|bottom"
                  android:layout_margin="@dimen/material_component_floating_action_button_margin"
                  android:src="@drawable/ic_add_white_24dp"
                  android:visibility="gone"
                  android:fitsSystemWindows="false"
                  app:backgroundTint="@color/accent"
                  app:elevation="@dimen/elevation_fab_resting"
                  app:fabSize="normal" /&gt;
  
  
              &lt;android.support.design.widget.FloatingActionButton
                  android:id="@+id/frag_drawer_fab_filter"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_gravity="end|bottom"
                  android:layout_margin="@dimen/material_component_floating_action_button_margin"
                  android:fitsSystemWindows="false"
                  android:src="@drawable/ic_filter"
                  android:visibility="visible"
                  app:backgroundTint="@color/accent"
                  app:elevation="@dimen/elevation_fab_resting"
                  app:fabSize="normal" /&gt;
          &lt;/android.support.design.widget.CoordinatorLayout&gt;
  
  
          &lt;android.support.design.widget.NavigationView
              android:id="@+id/frag_drawer_nav"
              android:layout_width="wrap_content"
              android:layout_height="match_parent"
              android:layout_gravity="start"
              app:elevation="@dimen/elevation_nav_drawer"
              app:headerLayout="@layout/layout_nv_header"
              app:itemIconTint="@color/nav_icon_tint"
              app:itemTextColor="@color/nav_text"
              app:menu="@menu/menu_drawer" /&gt;
  
      &lt;/android.support.v4.widget.DrawerLayout&gt;
  &lt;/layout&gt;
  </code></pre>
  
  <h2>My Question</h2>
  
  <p>How can I show and hide the Status bar and the Navigation View more smoothly ?</p>