15

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!

LEE
  • 3,335
  • 8
  • 40
  • 70
  • read ViewGroup docs, pay attention on intercepting MotionEvents – pskink Mar 10 '15 at 13:24
  • Possible duplicate of [RecyclerView inside ScrollView is not working](https://stackoverflow.com/questions/27083091/recyclerview-inside-scrollview-is-not-working) – Adil Hussain Apr 01 '18 at 09:51

3 Answers3

46

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.

mipreamble
  • 1,415
  • 12
  • 17
6

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.
Community
  • 1
  • 1
waqaslam
  • 67,549
  • 16
  • 165
  • 178
  • 1
    Great. Finally I sorted it out. What I did is dynamically using my recycler view layout position. Problem solved ! – LEE Mar 12 '15 at 06:29
  • @Abhilash, Please share the answer. – Muhammad Riyaz Aug 12 '15 at 09:48
  • 1
    @MuhammadRiyaz i have used this: http://stackoverflow.com/a/27616854/3736955 . But scrolling scrollview is not smooth . So used below answer (http://stackoverflow.com/a/32283439/3736955) to make it smooth – Jemshit Sep 03 '15 at 08:50
1

Add this line in xml,

android:nestedScrollingEnabled="false"
F_Z
  • 581
  • 3
  • 16