Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to apply Smooth vertical Scrolling in NestedScrollView in android

Tags:

android

<android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="15dp"
            android:background="#e7e7e8"
            android:orientation="vertical"
            tools:ignore="RtlHardcoded">

            <android.support.v7.widget.RecyclerView
                android:id="@+id/recyclerView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

            <android.support.v7.widget.RecyclerView
                android:id="@+id/communication_recyclerView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />


            <android.support.v7.widget.RecyclerView
                android:id="@+id/vision_recyclerView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />


            <android.support.v7.widget.RecyclerView
                android:id="@+id/hearing_recyclerView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />


            <android.support.v7.widget.RecyclerView
                android:id="@+id/physical_dependency_recyclerView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />


            <android.support.v7.widget.RecyclerView
                android:id="@+id/selef_care_recyclerView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"

                />

        </LinearLayout>
    </android.support.v4.widget.NestedScrollView>

This is my code i have take 6 RecyclerView inside NestedScrollView but when i scroll vertically smooth scrolling is not working can any one please suggest me how to apply smooth scrolling in NestedScrollView

like image 871
Adevelopment Avatar asked Aug 28 '17 06:08

Adevelopment


2 Answers

Adding recyclerviews inside NestedScrollView does not make good practice. Avoid these kind of situation if possible.
Here are some alternatives...

  • Use items as recyclerview items - Kind of multiple type recyclerview
  • Use horizontal orientation of recyclerview to show content well.
like image 180
Paresh P. Avatar answered Oct 20 '22 06:10

Paresh P.


If you are using RecyclerView inside NestedScrollView then use mRecyclerView.setNestedScrollingEnabled(false);

If in case it does not work smoothly scrolling for RecyclerView inside NestedScrollView OR Only NestedScrollView then make sure that your compileSdkVersion match with your currently used library version.

For example. In your all build.gradle file compileSdkVersion 25 buildToolsVersion '25.0.3'

Then your support appcompact library version

compile "com.android.support:appcompat-v7:25.3.1"

if you can't find your mismatch library version then run below command in Android Studio Terminal. it should fetch currently used library version and latest library version according compileSdkVersion.

./gradlew -q dependencies app:dependencies --configuration compile

like image 39
Patrick R Avatar answered Oct 20 '22 07:10

Patrick R