how to show/hide FAB on scroll Recycler view with coordinator parent

I modified Leondro's method such that the FAB will hide when there's scrolling and show when the scrolling stops.

scrollListener = new RecyclerView.OnScrollListener() {  
    @Override
    public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
        switch (newState) {
            case RecyclerView.SCROLL_STATE_IDLE:
                fab.show();
                break;
            default:
                fab.hide();
                break;
        }
        super.onScrollStateChanged(recyclerView, newState);
    }
}; 

rv.clearOnScrollListeners();
rv.addOnScrollListener(scrollListener);

This code works just fine:

 mRecycler.addOnScrollListener(new RecyclerView.OnScrollListener() {
                @Override
                public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                    if(dy > 0){
                        mFab.hide();
                    } else{
                        mFab.show();
                    }

                    super.onScrolled(recyclerView, dx, dy);
                }
            });

You cannot do:

app:layout_anchor="@id/listView"
app:layout_anchorGravity="bottom|end"

Look here:

There is no support built-in for CoordinatorLayout to work with ListView according to this Google post.