iPaulPro / Android-ItemTouchHelper-Demo

Basic example of using ItemTouchHelper to add drag & drop and swipe-to-dismiss to RecyclerView.
Apache License 2.0
2.51k stars 498 forks source link

Dragging jumps several rows when padding is set on RecyclerView #18

Open timothyjc opened 9 years ago

timothyjc commented 9 years ago

Use this layout to see this issue then try and drag the last item in the list/grid upwards to see it jump several positions:

<android.support.v7.widget.RecyclerView
    android:id="@+id/recycler_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clipChildren="false"
    android:clipToPadding="false"
    android:paddingBottom="150dp"
    android:paddingTop="150dp" />
AkshayChordiya commented 8 years ago

@timothyjc I too am seeing this issue. My code is shown below:

<android.support.v7.widget.RecyclerView
        android:id="@+id/songs_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipToPadding="false"
        android:paddingTop="16dp"/>

The last item creates a weird situation. I hope @iPaulPro fixes it soon. Thank you so much.

gajicm93 commented 8 years ago

Any news on this?

serhii-k commented 6 years ago

It happens when the paddingTop is set to more than 0dp. Has anyone found a workaround/fix?

serhii-k commented 6 years ago

Well. Instead of setting the top and bottom paddings, you can create a special type of a ViewHolder to mimic paddings, then disable its movement. Here you can find how to implement this: https://github.com/iPaulPro/Android-ItemTouchHelper-Demo/issues/4