how to disable recycler view scrolling so that it

2019-04-04 18:21发布

问题:

I have a recycler view inside a ScrollView. I want to disable the recycler view scroll so that it listens to its parent layout, A ScrollView!

回答1:

Logically, it is not a good idea to put ListView inside a ScrollView. However, if you insist then:

  • You may either increase the ListView height based on the sum of its rows height as mentioned here.
  • Or let the recycling in place but intercept the touch on ListView to redirect scrolling to its parent ScrollView as mentioned here.


回答2:

This should solve your RecyclerView nested scrolling.

 mRecyclerView.setNestedScrollingEnabled(false);

RecyvlerView implements NestedScrollingChild

for instance if RecyclerView parent is a ScrollView or ListView or RecyclerView or any AbsListView

disable scrolling for the child RecyclerView.