Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NestedScrollView not fling with Recyclerview inside

Tags:

java

android

I have a layout like that:

<NestedScrollView>      <RecyclerView> // vertical recycler view           <RecyclerView/>  // horizontal recycler view           <RecyclerView/>           <RecyclerView/>           ...      <RecyclerView> </NestedScrollView> 

The result looks like Google play store: enter image description here

And I disabled NestedScrolling in horizontal Recycler view:

horizontalRecyclerView.setHasFixedSize(true); horizontalRecyclerView.setNestedScrollingEnabled(false); 

My problem:

The vertical recyclerview does not scroll fling, whenever ACTION_UP happen, the vertical recyclerview also stop scrolling.

How can I nest vertical recyclerview inside nestedscrollview, and horizontal recyclerview inside vertical recyclerview like Playstore and keep the scroll smooth.

Solved:

Using custom nested scroll view of @vrund purohit (code below), and disabled nestedscroll both vertical and horizontal recyclerview:

verticalRecyclerView.setNestedScrollingEnabled(false); ... add each horizontal recyclerviews: horizontalRecyclerView.setNestedScrollingEnabled(false); 
like image 633
Khang .NT Avatar asked May 23 '16 07:05

Khang .NT


People also ask

How do I prevent NestedScrollView from scrolling if body is small?

The problem can be solved by moving the SliverAppBar into the CustomScrollView and not use the NestedScrollView at all.

What is difference between nested ScrollView and NestedScrollView?

Nested scrolling is enabled by default. Show activity on this post. NestedScrollView is just like ScrollView, but in NestedScrollView we can put other scrolling views as child of it, e.g. RecyclerView. But if we put RecyclerView inside NestedScrollView, RecyclerView's smooth scrolling is disturbed.

How do I make my RecyclerView scroll smooth?

Also, if you are using a recycler view inside the scroll view, make sure to set nested scrolling to false. Show activity on this post. Use a library as said by other comments in here. Also make sure you do not have Recyclerviews nested within a Scrollview.

How do I use NestedScrollView?

NestedScrollView is just like ScrollView, but it supports acting as both a nested scrolling parent and child on both new and old versions of Android. It is enabled by default. NestedScrollView is used when there is a need for a scrolling view inside another scrolling view.


2 Answers

Use below code for smooth scroll:

ViewCompat.setNestedScrollingEnabled(recyclerView, false); 
like image 52
Kuldeep Sakhiya Avatar answered Sep 18 '22 17:09

Kuldeep Sakhiya


Add this in your RecyclerView xml:

android:nestedScrollingEnabled="false" 
like image 30
jbc25 Avatar answered Sep 19 '22 17:09

jbc25