Skip to content

Instantly share code, notes, and snippets.

@EfeBudak
Created June 29, 2018 07:52
Show Gist options
  • Save EfeBudak/ec165e70cad985445796db3eede0c90b to your computer and use it in GitHub Desktop.
Save EfeBudak/ec165e70cad985445796db3eede0c90b to your computer and use it in GitHub Desktop.
recyclerView.layoutManager = object :
LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) {
override fun onLayoutCompleted(state: RecyclerView.State?) {
super.onLayoutCompleted(state)
if (showReturnToTopButton
&& (findLastVisibleItemPosition()
- findFirstVisibleItemPosition()
+ 1
< adapter.itemCount)) {
buttonReturnToTop.visibility = View.VISIBLE
showReturnToTopButton = false
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment