In my RecyclerView
I have some items that user can scroll and see that. Now I want to save this position and scroll that after come back. This below code return
This is the extension function in Kotlin:
private fun RecyclerView.getCurrentPosition() : Int {
return (this.layoutManager as LinearLayoutManager?)!!.findFirstVisibleItemPosition()
}
You can use it just invoking this function on your RecyclerView
:
val position = yourRecyclerView.getCurrentPosition()