Created
November 26, 2019 09:21
-
-
Save rajumark/7010d0d5d19bf920d938cbdb37ad2897 to your computer and use it in GitHub Desktop.
get recyclerview center item position based on layoutmanager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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