1

I wrote this function to handle scrolling for my nested VERTICAL recycler views. ( both of them vertical ! I have disabled nestedScrolling in the child recycler Views )

    val mgr: LinearLayoutManager = vList.layoutManager as LinearLayoutManager
    val iFirst: Int = mgr.findFirstCompletelyVisibleItemPosition()
    val iLast: Int = mgr.findLastCompletelyVisibleItemPosition()

    // Auto-Scroll:
    if (mgr.findViewByPosition(iFirst) === viewHoveredOver) toScroll.scrollBy(0,-35)
    else if (mgr.findViewByPosition(iLast) === viewHoveredOver) toScroll.scrollBy(0,35)
}

But... turns out : The child recycler view always returns the LAST and FIRST item position in findLastCompletelyVisibleItemPosition/findFirstCompletelyVisibleItemPosition , instead of the actual visible items !

that is : if the item count is 10 & visible items is 4 , findLastCompletelyVisibleItemPosition would still return 9 , instead of 3

Divesh
  • 112
  • 1
  • 6

0 Answers0