Skip to content

Instantly share code, notes, and snippets.

@robsn
Created March 21, 2018 08:28
Show Gist options
  • Save robsn/3982a3065a1c2db3b05e9a7c0d69cff3 to your computer and use it in GitHub Desktop.
Save robsn/3982a3065a1c2db3b05e9a7c0d69cff3 to your computer and use it in GitHub Desktop.
Hide Show Scrolling FAB
dashboard.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView?, dx: Int, dy: Int) {
if (dy > 0 || dy < 0 && fab.isShown) {
fab.hide()
}
super.onScrolled(recyclerView, dx, dy)
}
override fun onScrollStateChanged(recyclerView: RecyclerView?, newState: Int) {
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
fab.show()
}
super.onScrollStateChanged(recyclerView, newState)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment