Home » Android » nestedrecyclerview inside recyclerview not scrolling android-Exceptionshub

nestedrecyclerview inside recyclerview not scrolling android-Exceptionshub

Posted by: admin February 26, 2020 Leave a comment

Questions:

            <ImageView
                android:id="@+id/settings"
                android:layout_width="@dimen/_30sdp"
                android:layout_height="@dimen/_30sdp"
                android:layout_marginTop="@dimen/_5sdp"
                android:background="@mipmap/menu" />

            <TextView
                android:id="@+id/title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_gravity="center"
                android:layout_marginLeft="@dimen/_12sdp"
                android:layout_marginTop="5dip"
                android:layout_weight="1"
                android:fontFamily="@font/montserrat"
                android:gravity="center"
                android:text="2019"
                android:textColor="#EDF0F5"
                android:textSize="19dip"
                android:textStyle="bold" />    
            <ImageView
                android:id="@+id/addPeople"
                android:layout_width="@dimen/_30sdp"
                android:layout_height="@dimen/_30sdp"
                android:layout_marginTop="@dimen/_5sdp"/>
        </LinearLayout>     
        <android.core.widget.NestedScrollView
            android:id="@+id/nestedScrollView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/l1"
            android:layout_gravity="fill_vertical"
            android:fillViewport="true"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">
            <android.recyclerview.widget.RecyclerView
                android:id="@+id/rv_item"    
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="@dimen/_7sdp"
                tools:targetApi="lollipop" />
        </androidx.core.widget.NestedScrollView>
    </RelativeLayout>    
    <include layout="@layout/listhome" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

i written above xml code in my application recyclerview showing but not scrolling if i add nestedscrollview android i written above xml code in my application recyclerview showing but not scrolling if i add nestedscrollview android

How to&Answers:

You’re nesting a recycler view inside another scrollable viewgroup i.e. NestedScrollView, Both have there own scroll mechanisms but since parent is NestedScrollView the child RecyclerView will loose its ability to scroll properly.

Solution to your problem is just disabling nested scrolling on recycler view.

Try this:

ViewCompat.setNestedScrollingEnabled(recyclerView,false);