ItemTouchHelper with RecyclerView in NestedScrollView: scroll drag and drop does not work

I implemented ItemTouchHelper as described in this article: https://medium.com/@ipaulpro/drag-and-swipe-with-recyclerview-b9456d2b1aaf#.k7xm7amxi

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

But if the RecyclerView is a child of the NestedScrollView in the CoordinatorLayout, drag and drop scrolling no longer works. By dragging an item and moving it to the top or bottom of the screen, the RecyclerView does not scroll as if it were not a child of the NestedScrollView.

Any ideas?

+6
source share
2 answers

You must disable nestedScrollingto recyclerView:

recyclerViewAdapter.setIsNestedScrollingEnabled(false);
0
source

android: descendantFocusability = "blocksDescendants"

add to NestedScrollView and add

android: focusableInTouchMode = "true"

in the child layout it looks below

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

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

</androidx.core.widget.NestedScrollView>
0
source

Source: https://habr.com/ru/post/1656012/


All Articles