google / flexbox-layout

Flexbox for Android
Apache License 2.0
18.24k stars 1.79k forks source link

Items outside viewport cannot be accessed with D-Pad on Android TV #576

Open mrdezzods opened 3 years ago

mrdezzods commented 3 years ago

Issues and steps to reproduce

FlexboxLayoutManager has an issue with D-Pad scrolling. When the grid is scrolled with swipe (tested on emulator), items outside the initial viewport are displayed and can be scrolled to, but when navigating down or up with d-pad, items which were not initially loaded are not accessible

To reproduce the issue, create a RecyclerView and set LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT) as layoutParams. Add FlexboxLayoutManager as its layout manager and add CardView as child presenter. Then add about 40 items in recyclersview's adapter.

Expected behavior

Viewport displays about 20 cards (5 columns, 4 rows). I expect it to scroll to items below when navigating with D-Pad

Version of the flexbox library

2.0.1

Link to code

val recyclerView = RecyclerView(parent.context, null).apply {
            layoutParams =
                ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
        }
recyclerView.layoutManager = FlexboxLayoutManager(parent.context)