Skip to content

利用NestedScrolling机制,把RecyclerView嵌套在NestedScrollView中,实现嵌套滚动,RecyclerView复用回收机制不受影响

Notifications You must be signed in to change notification settings

coolfeng168/ScrollViewNestedRecyclerView

Repository files navigation

ScrollViewNestedRecyclerView

利用NestedScrolling机制,把RecyclerView嵌套在NestedScrollView中,实现嵌套滚动,RecyclerView复用回收机制不受影响

效果图:

image

使用方法:

<?xml version="1.0" encoding="utf-8"?>
<com.yunfeng.scrollviewnestedrecyclerviewdemo.ScrollViewNestedRecyclerView xmlns:android="http:https://schemas.android.com/apk/res/android"
    xmlns:tools="http:https://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:orientation="vertical">
        <TextView
            android:id="@+id/snr_top_view"
            android:layout_width="match_parent"
            android:layout_height="400dp"
            android:background="@color/colorPrimary"
            android:textColor="#fff"
            android:textSize="20sp"
            android:gravity="center"
            android:text="这是scrollview部分"/>

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/snr_recycler_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>

    </LinearLayout>


</com.yunfeng.scrollviewnestedrecyclerviewdemo.ScrollViewNestedRecyclerView>

About

利用NestedScrolling机制,把RecyclerView嵌套在NestedScrollView中,实现嵌套滚动,RecyclerView复用回收机制不受影响

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages