I have an activity with coordinator layout.inside activity there is a fragment with Recycler view and float button.how can I show/hide float button when Scroll Recycler view and
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);