rubensousa / DpadRecyclerView

A RecyclerView built for Android TV with Compose in mind and as a replacement for Leanback's BaseGridView.
https://rubensousa.github.io/DpadRecyclerView/
Apache License 2.0
136 stars 17 forks source link

Vertical list with focus centered #177

Closed smin9 closed 10 months ago

smin9 commented 11 months ago

Hello, I encountered a problem, I set recyclerView.setParentAlignment( ParentAlignment(fraction = 0.5f) ) recyclerView.setChildAlignment( ChildAlignment(fraction = 0.5f) ) to center the focus, but I want that when the remote control is pressed, when the next item in the list gets focus, it does not get focus on the first item, but gets focus right below it. What should I do? WechatIMG76

rubensousa commented 11 months ago

Hi @smin9. To achieve this, you have 2 alternatives:

  1. Set the edge alignment parameter to NONE: https://rubensousa.github.io/DpadRecyclerView/alignment/#aligning-to-an-edge
  2. Intercept the focus change in the root layout and find the center position manually.

Approach 2 is more complex and requires manual work, but it's definitely possible. Anyway, I would really avoid deviating too much from the default behaviours for UX consistency.

rubensousa commented 10 months ago

@smin9 closing this since this is already supported