Android – Disable Scrolling in child Recyclerview android

androidandroid-listviewandroid-recyclerview

I have a layout consists of a Parent RecyclerView with a sub Recyclerview in it

i know that it is not good to put a list inside another list but i have to so that i can use the sub list features like swiping and drag and drop

My issue is that the child Recyclerview gain focus and stops the parent from scrolling if the touch point was on it
simply i want if the touch was vertically on the child Recyclerview
the parent scrolls up and down and if the touch was horizontal or a click then the child Recyclerview list item swipes left and right.
Any help to achieve this?

Best Solution

I finally found a solution.

Create Custom LinearLayoutManager

public class CustomLinearLayoutManager extends LinearLayoutManager {
public CustomLinearLayoutManager(Context context, int orientation, boolean reverseLayout) {
    super(context, orientation, reverseLayout);

}

// it will always pass false to RecyclerView when calling "canScrollVertically()" method.
@Override
public boolean canScrollVertically() {
    return false;
}
}

Then instantiate it like this for vertical scrolling

CustomLinearLayoutManager customLayoutManager = new CustomLinearLayoutManager(getActivity(),LinearLayoutManager.VERTICAL,false);

Finally set the custom layout as layout manager of recycler view

recyclerView.setLayoutManager(customLayoutManager);