0

I have a horizontal recycler view inside vertical nested scroll view. Everything works fine until there is no item inside recycler view once item added inside recycler view the scroll view starts lagging(not scrolling smoothly)

I have tried almost everything. like: //recycler view additionalList.setNestedScrollingEnabled(false);

Recycler View layout(inside child fragment):

 <RelativeLayout
        android:focusableInTouchMode="true"
        android:focusable="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <LinearLayout

            android:id="@+id/add_image"
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:layout_marginTop="@dimen/default_margin"
            android:background="@color/grey1"
            android:gravity="center">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/ic_add_image" />
        </LinearLayout>

        <android.support.v7.widget.RecyclerView
            android:layout_marginTop="@dimen/default_margin"
            android:id="@+id/additional_art_list"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/add_image" />
    </RelativeLayout>

Nested Scroll View Layout(Fragment Container):

    <NestedScrollView    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:autolabel="http://schemas.android.com/apk/res-auto"
    android:id="@+id/observableScrollView"
    android:fillViewport="true"
    android:overScrollMode="never"
    android:scrollbars="none"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
  <FrameLayout
            android:layout_marginTop="@dimen/default_margin"
            android:layout_below="@id/container_purchase_detail"
            android:id="@+id/container_premium_features"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
 </FrameLayout>
</NestedScrollView>

1 Answers1

0

If you are using Recyclerview inside NestedScrollView than prelolipop devices use this code when you are setting adapter

 if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
        recyclerView.setNestedScrollingEnabled(false);
    }

and set android:nestedScrollingEnabled false in layout file in RecyclerView

  android:nestedScrollingEnabled="false"
Mohit Suthar
  • 6,717
  • 8
  • 28
  • 56