flexbox-layout icon indicating copy to clipboard operation
flexbox-layout copied to clipboard

When applied to TV with the FlexboxLayoutManager, There's some problems with focus change

Open akjbm opened this issue 6 years ago • 4 comments

When applied to TV with the FlexboxLayoutManager, I can not flip the page with the down button correctly,and when the focused view is on end of a line ,I press the right button ,nothing happened。

akjbm avatar Jun 29 '18 06:06 akjbm

It needs more info. Do you have an example project that I can reproduce the issue?

thagikura avatar Jun 30 '18 13:06 thagikura

Hi Thagikura, We are facing some focus issues in TV application for FlexBoxLayoutmanager. On moving right from last item of the each FlexLine, the focus goes missing from flex layout (jumps randomly). FlexboxLayout.getFlexLines() returns (number of lines - 1) as result. Can you please help me with a suggestion on how to handle the focus on extreme end items of each flex lines? Details requirement: How can we focus on the next line first item when the last item of previous line is reached or keep the focus on that item itself. Similarly, How to stop the focus on first item of each line on left button click or move to the last item of previous line.

Thanks in advance.

subhalaxmi avatar Jun 10 '19 07:06 subhalaxmi

I am able to reproduce this using the demo-cat-gallery app.

Test plan:

  • Using you finger, scroll down until the "Cat Gallery" toolbar collapses.
  • Using a bluetooth keyboard or with the emulator, press the down button until you reach the last element that is visible on screen
  • Press the down button again
  • Expected behavior: The recyclerview scrolls down and the next viewholder down gains focus.
  • Actual behavior: The first element on screen gains focus

I think this bug is caused because FlexboxLayoutManager does not implement getExtraLayoutSpace() like LinearLayoutManager does. That class predraws a couple items off of the screen so that they could be navigated to using a keyboard. The FlexboxManager only creates items that are on screen.

See: https://github.com/google/flexbox-layout/blob/0edae6d3b2efedd42d8e3623e0f89f6cc5c55f07/flexbox/src/main/java/com/google/android/flexbox/FlexboxLayoutManager.java#L2990 https://developer.android.com/reference/androidx/recyclerview/widget/LinearLayoutManager#calculateExtraLayoutSpace(androidx.recyclerview.widget.RecyclerView.State,%20int[])

In this video I am pressing the tab button to go down then shift+tab to go backwards. Notice how the list doesn't scroll when I reach the end:

https://user-images.githubusercontent.com/6628497/103239146-b59ee980-491a-11eb-86a9-5e3fb879f47e.mp4

TylerCarberry avatar Dec 28 '20 19:12 TylerCarberry

Hello We are having a similar issue. Did anyone find a solution for this?

mrdezzods avatar May 07 '21 07:05 mrdezzods