Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nested scroll View not scrolling smoothly with recyclerview android

Tags:

android

I am using Nested Scrollview to wrap the recyclerview and other button. It worked perfectly but I noticed that when I scrolled it not smooth. Please guide how to make scrolling smooth.

 <android.support.v4.widget.NestedScrollView
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:id="@+id/scrollView"
                        android:fillViewport="true">
                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:orientation="vertical">
                            <LinearLayout
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content">
                                <Button
                                    android:layout_width="match_parent"
                                    android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_action_filter"
                                    android:text="Filter"
                                    android:id="@+id/btn_filter"
                                    android:layout_margin="0dp"
                                    android:layout_weight="1"
                                    />
                                <Button
                                    android:layout_width="match_parent"
                                    android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_action_sortbyt"
                                    android:layout_margin="0dp"
                                    android:text="Sort By"
                                    android:id="@+id/btn_sortby"
                                    android:layout_weight="1"/>
                            </LinearLayout>
                            <android.support.v7.widget.RecyclerView
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:id="@+id/lastest_product_list"
                                android:nestedScrollingEnabled="false"
                                android:isScrollContainer="false">
                            </android.support.v7.widget.RecyclerView>
                        </LinearLayout>
                    </android.support.v4.widget.NestedScrollView>
like image 387
Angkor Empire Avatar asked Dec 14 '16 03:12

Angkor Empire


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.

How do I stop NestedScrollView scrolling?

setnestedscrollingenabled set it to false. try this one add property in recyclerview android:descendantFocusability="blocksDescendants" .

Is nestedScrollingEnabled false?

Bug: android:nestedScrollingEnabled="false" causes crash on RecyclerView, yet setNestedScrollingEnabled(false) doesn't.


2 Answers

As per Android documentation android:nestedScrollingEnabled="false" works, but only on Android API level >= 21.

If you want to support devices below API 21 as well, use the following:

ViewCompat.setNestedScrollingEnabled(recyclerView, false);
like image 98
TejaDroid Avatar answered Sep 18 '22 09:09

TejaDroid


try below codes:

 RecyclerView recycleView = (RecyclerView) findViewById(R.id.lastest_product_list);
    recycleView.setNestedScrollingEnabled(false);

You can modify your layout

<ScrollView>
     <LinearLayout> 
         <android.support.v7.widget.RecyclerView
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:id="@+id/lastest_product_list"
              android:nestedScrollingEnabled="false"
              android:isScrollContainer="false">
        </android.support.v7.widget.RecyclerView>
    </LinearLayout>

Check with link here : Recyclerview inside ScrollView not scrolling smoothly

like image 34
Manikandan K Avatar answered Sep 20 '22 09:09

Manikandan K