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

Scroll position start question #172

Closed miomao656 closed 11 months ago

miomao656 commented 11 months ago

Hi,

<com.rubensousa.dpadrecyclerview.DpadRecyclerView
        android:layout_width="130dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_marginStart="5dp"
        android:layout_marginTop="20dp"
        android:layout_marginEnd="5dp"
        android:layout_marginBottom="5dp"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:gravity="center"
        android:orientation="vertical"
        tools:listitem="@layout/nav_menu_group_item" />

i get a small list that is a couple of cells and all content aligns to top, and i need it to be in the center vertical. When the list is big to fill the screen there is normal behaviour that scrolls from/to the middle of list. Is there a way to center vertical the content and have it be scrolled the same way as it is when the list is bigger?

rubensousa commented 11 months ago

Hi @miomao656. Yes, that should be possible by customising the parent alignment configuration. Check this: https://rubensousa.github.io/DpadRecyclerView/alignment/#aligning-to-an-edge

In your case, you're looking for app:dpadRecyclerViewParentAlignmentEdge=none

Please let me know if this is the behavior you're looking for

miomao656 commented 11 months ago

When i add app:dpadRecyclerViewParentAlignmentEdge=none the list with less items on the screen than the height starts at the middle of the screen and as i scroll trought the items down the list shifts up the screen.

This is fine but when i scroll up, the list does not return and the focused item goes up the screen.

Also first item in the list is only half visible when you scroll up.

Is there a way to focused item stay in center and the list just shifts up or down, depending on scroll direction?

rubensousa commented 11 months ago

@miomao656 can you please provide a screen recording of that behavior? What you're describing might be a bug, as scrolling up should return to the original state

miomao656 commented 11 months ago

https://github.com/rubensousa/DpadRecyclerView/assets/6882632/4214c4d4-23f6-4bc2-add5-9dc367dcf59d

here is the video

rubensousa commented 11 months ago

Are you using wrap_content in the height? If yes, that's not properly supported if you're in a vertical orientation. Please use match_parent or give it a fixed height

rubensousa commented 11 months ago

Also, which version are you using at the moment?

miomao656 commented 11 months ago

i am using 1.2.0 alfa 1, here is a recording with match parent for height and fixed width.

https://github.com/rubensousa/DpadRecyclerView/assets/6882632/0ab1d774-6af9-4077-bd5f-6151cab33953

rubensousa commented 11 months ago

Ok, this seems indeed a bug. I will look into it. For now, as a workaround, can you try using app:dpadRecyclerViewParentAlignmentEdge=min to see if it suits your needs?

miomao656 commented 11 months ago

The best i could come up with is using max.

https://github.com/rubensousa/DpadRecyclerView/assets/6882632/695db878-fa80-496f-bfcd-eb911716d1f6

and for min and min_max i get this behaviour

https://github.com/rubensousa/DpadRecyclerView/assets/6882632/0a422fd7-2683-4fb9-8146-556d564d8013

rubensousa commented 11 months ago

Thank you for sending the recordings. I will have a look at this issue and reply here with the fix once it's available

miomao656 commented 11 months ago

Tnx for the quick response.

Library is awesome, so keep up the good work!

rubensousa commented 11 months ago

@miomao656 fix will be available in the next release: 1.2.0-alpha02

miomao656 commented 11 months ago

Thank you! When do you plan to release ti?

rubensousa commented 11 months ago

@miomao656 fix released in 1.2.0-alpha02