Disable Scrolling in child Recyclerview android

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);

Leave a Comment