Home > Software design >  how to focus a specific item in recycler view?
how to focus a specific item in recycler view?

Time:08-12

I have 50 items in my recycler view. I want to focus or show specific item like when I click on button 1 it will focus items 10, and when I click on button 2 it will show/focus on items 30 and so on.

CodePudding user response:

If you are looking for how to scroll to that 10th and 30th item then below solution is for you.

recyclerView.getLayoutManager().scrollToPosition(position)

Here position is, in which position you want to scroll

for highlight that item you can change text format like bold or color of that item of recycler view

Happy Coding :)

CodePudding user response:

You can use the RecyclerView directly for that.

Scroll to item:

  • with animation
recyclerView.smoothScrollToPosition(itemPosition)
  • without animation
recyclerView.scrollToPosition(itemPosition)
  • Related