Home > Software design >  Horizontal RecyclerView - when selected item is out of viewport (scrolling left/right), change backg
Horizontal RecyclerView - when selected item is out of viewport (scrolling left/right), change backg

Time:09-12

So I have a horizontal recyclerview that can be scrolled both left and right (around 50 items in it). When the selected item in the recycler view is out of viewport, because I scrolled right, I want to change the background of the most right item, as an indicator that selected item is on the right, and same if I scroll left.

Not sure if I could use findLastCompletelyVisibleItemPosition(), because how would I get the position of the right/left most item?

CodePudding user response:

to get the right most item, you can use findLastCompletelyVisibleItemPosition() and to get the left most item, you can use findFirstCompletelyVisibleItemPosition()

  • Related