I layout a RecyclerView
in a NestedScrollView
and I want make the NestedScrollView
scroll with RecyclerView
, but this only happens when the recyclerView reach the end, below is my layout code:
<android.support.v4.widget.NestedScrollView
android:id="@+id/lists_frame"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
tools:context="com.example.niuky.design.MainActivity4"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<View
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="256dp"
android:background="@color/material_blue_grey_800"
/>
<View
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="@color/material_blue_grey_950"
/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="700dp"
/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
This is my runtime view:
<android.support.v4.widget.NestedScrollView
android:id="@+id/nested_scrollbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:scrollbars="none" >
<LinearLayout
android:id="@+id/nested_scrollbar_linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<android.support.v7.widget.CardView
android:id="@+id/flexible.example.cardview"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.CardView>
<android.support.v7.widget.RecyclerView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
and apply .setNestedScrollingEnabled
to recyclerview
and set it to false
P.s: for Api lower 21 :
ViewCompat.setNestedScrollingEnabled(recyclerView, false);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With