rubensousa / GravitySnapHelper

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

GravitySnapHelper ignores RecyclerView padding in 2.0 #58

Closed CodeBreak524 closed 5 years ago

CodeBreak524 commented 5 years ago

In version 1.5 GravitySnapHelper respected paddings of RecyclerView, which it was attached to. For example, using helper Gravity.START to recycler with paddingLeft > 0 was correctly handled, i.e. this padding remained while snapping to next elements. But in 2.0 this padding is ignored while snapping and this leads to layout break.

Example of used RecyclerView:

GravitySnapHelper(Gravity.START).attachToRecyclerView(recyclerView)

<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/recyclerView"
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:layout_marginLeft="0dp"
    android:layout_marginRight="0dp"
    android:clipToPadding="false"
    android:nestedScrollingEnabled="false"
    android:paddingLeft="5dp"
    android:paddingRight="5dp" />

Layout of item used seems to be insignificant for this.

rubensousa commented 5 years ago

I just checked this using the sample. There's a list titled "Snap start with padding" and it seems to work fine.

Can you provide a screenshot of the behavior you're looking for VS what it's like at the moment?

VinhTranVN commented 5 years ago

Hello @rubensousa, I have the same issue above on 2.1.0, it worked OK on 1.5, you can check the attached images, I hope they can provide more info.

version 1.5

1 5

version 2.1.0

2 1 0
rubensousa commented 5 years ago

@VinhTranVN thank you for the example :)

I'll check this once I have more time.

rubensousa commented 5 years ago

Released in 2.2.0. Use this: https://github.com/rubensousa/GravitySnapHelper/blob/2.2.0/gravitysnaphelper/src/main/java/com/github/rubensousa/gravitysnaphelper/GravitySnapHelper.java#L324

By default this is false, so you need to call that and pass true