Android-ItemTouchHelper-Demo icon indicating copy to clipboard operation
Android-ItemTouchHelper-Demo copied to clipboard

Dragging jumps several rows when padding is set on RecyclerView

Open timothyjc opened this issue 10 years ago • 4 comments

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" />

timothyjc avatar Sep 10 '15 23:09 timothyjc

@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.

AkshayChordiya avatar Nov 04 '15 10:11 AkshayChordiya

Any news on this?

gajicm93 avatar Jul 13 '16 10:07 gajicm93

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

serhii-k avatar Nov 07 '17 18:11 serhii-k

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

serhii-k avatar Nov 07 '17 23:11 serhii-k