title: FloatingActionButton on scroll down hidden effect
body: <p>I am trying to make <code>floatingActionButton</code> hide when scroll down and showing again when scroll up, I used <code>setOnScrollChangeListener</code> for ScrollView to doing that</p>
  <p><strong>the XML</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;android.support.design.widget.CoordinatorLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      tools:context=&quot;.DetailsActivity&quot;
      android:orientation=&quot;vertical&quot;&gt;
  
      &lt;android.support.design.widget.FloatingActionButton
          android:id=&quot;@+id/fab&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          app:layout_anchor=&quot;@id/linearLayout&quot;
          app:layout_anchorGravity=&quot;start|bottom&quot;
          android:layout_margin=&quot;16dp&quot;
          android:src=&quot;@drawable/icons8_share_480&quot;
          /&gt;
  </code></pre>
  <p><strong>code</strong></p>
  <pre><code>if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.M) {
      scrollView.setOnScrollChangeListener(new View.OnScrollChangeListener() {
          @Override
          public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
              if (scrollY &gt; 0 &amp;&amp; fab.isShown()) {
                  fab.setVisibility(View.GONE);
              } else if (scrollY &lt; 0) {
                  fab.setVisibility(View.VISIBLE);
  
              }
          }
      });
  } else {
      scrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
          @Override
          public void onScrollChanged() {
              int mScrollY = scrollView.getScrollY();
              if (mScrollY &gt; 0 &amp;&amp; fab.isShown()) {
                  fab.setVisibility(View.GONE);
              } else if (mScrollY &lt; 0) {
                  fab.setVisibility(View.VISIBLE);
              }
          }
      });
  }
  </code></pre>
  <p><a href="https://i.imgur.com/vIWURB8.gifv" rel="nofollow noreferrer">the result</a>.
  <br/> It seems working but there are two problems sometimes when scroll the fab up does not appear, second it disappears directly without any effects the more clarify in this GIF <a href="https://i.imgur.com/3qYs32W.gifv" rel="nofollow noreferrer">Destination</a>.</p>