title: How to hide Floating Action Button on Nested Scroll
body: <p>I'm trying to hide two FAB on Nested Scroll scrolling. I've tried to implement my own FAB behavior but it did't work. FAB's don't react on scrolling at all. Note: I deleted some part of layout to fit the post.</p>
  
  <p>Layout</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.design.widget.CoordinatorLayout
      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"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:fitsSystemWindows="true"
      tools:context="ru.berezin.maxim.im.budget_v3.userinterface.StartPage"&gt;
  
      &lt;android.support.design.widget.AppBarLayout
          android:id="@+id/appcollapse"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"&gt;
      &lt;/android.support.design.widget.AppBarLayout&gt;
  
      &lt;android.support.v4.widget.NestedScrollView
          android:id="@+id/testingscroll"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:scrollbars="none"
          app:behavior_overlapTop="30dp"
          app:layout_behavior="@string/appbar_scrolling_view_behavior"&gt;
  
          &lt;!--content including--&gt;
          &lt;include layout="@layout/start_content_layout"/&gt;
  
      &lt;/android.support.v4.widget.NestedScrollView&gt;
  
      &lt;android.support.design.widget.FloatingActionButton
          android:id="@+id/start_page_fab"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="end|bottom"
          android:layout_margin="16dp"
          android:src="@drawable/plus"
          app:layout_anchor="@id/testingscroll"
          app:layout_anchorGravity="end|bottom"
          app:layout_behavior="ru.berezin.maxim.im.budget_v3.FabOnScroll"
          /&gt;
  
      &lt;View
          android:id="@+id/dummy"
          android:layout_width="1dp"
          android:layout_height="16dp"
          app:layout_anchor="@id/start_page_fab"
          app:layout_anchorGravity="top|right|end"
          /&gt;
  
      &lt;android.support.design.widget.FloatingActionButton
          android:id="@+id/account_det_add_transfer"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="end|top"
          android:layout_margin="16dp"
          android:src="@drawable/minus"
          app:layout_anchor="@id/dummy"
          app:layout_anchorGravity="top|right|end"
          app:layout_behavior="ru.berezin.maxim.im.budget_v3.FabOnScroll"
          /&gt;
  &lt;/android.support.design.widget.CoordinatorLayout&gt;
  </code></pre>
  
  <p>FabOnScroll class</p>
  
  <pre><code>public class FabOnScroll extends FloatingActionButton.Behavior {
          public FabOnScroll(Context context, AttributeSet attrs) {
              super();
          }
  
          @Override
          public void onNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
              super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
  
              //child -&gt; Floating Action Button
              if (dyConsumed &gt; 0) {
                  CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) child.getLayoutParams();
                  int fab_bottomMargin = layoutParams.bottomMargin;
                  child.animate().translationY(child.getHeight() + fab_bottomMargin).setInterpolator(new LinearInterpolator()).start();
              } else if (dyConsumed &lt; 0) {
                  child.animate().translationY(0).setInterpolator(new LinearInterpolator()).start();
              }
          }
  
          @Override
          public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View directTargetChild, View target, int nestedScrollAxes) {
              return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL;
          }
  
      }
  </code></pre>