Skip to content

Instantly share code, notes, and snippets.

@rajumark
Created November 26, 2019 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rajumark/7010d0d5d19bf920d938cbdb37ad2897 to your computer and use it in GitHub Desktop.
Save rajumark/7010d0d5d19bf920d938cbdb37ad2897 to your computer and use it in GitHub Desktop.
get recyclerview center item position based on layoutmanager
private fun giveMeCenterPosition(): Int {
val firstPos = layoutManager!!.findFirstVisibleItemPosition()
val lastPos = layoutManager!!.findLastVisibleItemPosition()
val middle = abs(lastPos - firstPos) / 2 + firstPos
return middle
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment