rubensousa / GravitySnapHelper

A SnapHelper that snaps a RecyclerView to an edge.
Apache License 2.0
5k stars 615 forks source link

the first item cannot snap to center #62

Closed jizhe7550 closed 4 years ago

jizhe7550 commented 4 years ago

When I try to set the gravity as Center and set the startPadding as the mid of the phone screen in horizontal, I found I cannot snap the first and the last view in some phone, such as Pixel, and it seems the second item is nearest than the first item to centre, but I don't know what I can change if I want to snap the first view in this situation, plz help me, thank you.

the decoration code

80dp

recyclerView.addItemDecoration( LinearEdgeDecoration( startPadding = screenWidth() / 2

fupduck commented 4 years ago

@jizhe7550 For me it helped adding padding to the RecyclerView

        android:clipToPadding="false"
        android:paddingLeft="100dp"
        android:paddingRight="100dp"
rubensousa commented 4 years ago

You need to have enough decoration or padding set for that to work. The sample app has a "Center with decoration" example