14

I have implemented ItemTouchHelper like descriped in this articel: https://medium.com/@ipaulpro/drag-and-swipe-with-recyclerview-b9456d2b1aaf#.k7xm7amxi

All works fine if the RecyclerView is a child of the CoordinatorLayout.

But if the RecyclerView is a child of NestedScrollView in CoordinatorLayout, the drag scrolling not working anymore. Draging an item and move it to the top or bottom of the screen, the RecyclerView not scrolling like it do if its not a child of NestedScrollView.

Any ideas?

Scrounger
  • 211
  • 1
  • 5

2 Answers2

1

You have to disable the nestedScrolling for the recyclerView:

recyclerView.setIsNestedScrollingEnabled(false);
Matt Robertson
  • 2,283
  • 5
  • 23
  • 51
Ourabi
  • 244
  • 2
  • 9
-1

android:descendantFocusability="blocksDescendants"

add in NestedScrollView and add

android:focusableInTouchMode="true"

in child layout it look like below

   <androidx.core.widget.NestedScrollView 
        android:descendantFocusability="blocksDescendants"> 

    <androidx.constraintlayout.widget.ConstraintLayout
        android:focusableInTouchMode="true">
        </androidx.constraintlayout.widget.ConstraintLayout> 

</androidx.core.widget.NestedScrollView>

check this github repo https://github.com/khambhaytajaydip/Drag-Drop-recyclerview

jai khambhayta
  • 2,263
  • 12
  • 24
  • This isn't working for me. Also it doesn't seem like a logical fix. Why would you set NestedScrollView to block descendants' focusability if you are setting it's descendant to be focusable? – Matt Robertson Aug 01 '19 at 14:15