0

In our fire tv app, we are using a nested recyclerview where every vertical item have a horizontal row as a child item like playstore design.

Scrolling with dpad working fine normally but when i hold the right key for few seconds, item start scrolling very fast because it gets many events & within few second focus goes to the next random row even current row has items to scroll. So this whole problem happening in horizontal scroll(child recyclerview). I have already tried many solutions like this, this, this.

Also tried the custom layout manager, custom focus layout & other approach like slowing down the recyclerview scroll etc approach but all not working.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433

1 Answers1

0

As far as I know, this happens at the moment when the last item is in focus, and the next item is not visible, that is, the ViewHolder has not updated the data of the first cell, so it is not clear which element to show next as if the list has ended.

You need to make sure that at least the edge of the next element is always visible on the screen.

Maybe you should play with the cell size or divider.

Edit: The secret is to use the leanback library. It isn't lost focus!

  1. Your gradle:
    // Leanback support

    def leanback_version = "1.2.0-alpha01" implementation("androidx.leanback:leanback:$leanback_version")

  2. Change in the layout from RecyclerView to HorizontalGridView (VerticalGridView)

  3. Change in the Fragment import from RecyclerView.widget.GridLayoutManager to androidx.leanback.widget.GridLayoutManager It works very fast for me and the focus no longer jumps.

Here a good article with animations but little outdated

kirkadev
  • 355
  • 4
  • 10