小编Edu*_*oks的帖子

在nestedscrollview中无限滚动的Recyclerview触发onScrolled

我在nestedscrollview中有recyclerview:

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

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <org.apmem.tools.layouts.FlowLayout
                android:id="@+id/filter_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/green_main"
                android:paddingLeft="@dimen/small_horizontal_margin"
                android:paddingRight="@dimen/small_horizontal_margin"
                />

            <android.support.v7.widget.RecyclerView
                app:layout_behavior="@string/appbar_scrolling_view_behavior"
                android:id="@+id/recycler_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:clipToPadding="false"
                android:scrollbars="vertical"
                android:paddingTop="@dimen/vertical_margin"/>

        </LinearLayout>
  </android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)

Recyclerview有OnScrollListener正在处理从这个例子采取无休止的滚动:https://guides.codepath.com/android/Endless-Scrolling-with-AdapterViews-and-RecyclerView.但是看起来nestedscrollview正在触发onScrolled方法,所以整个项目列表都会立即加载.

问题: 如何防止这种行为?

请注意,一切都适用于recyclerview,而不是在nestedscrollview中

android endlessscroll android-recyclerview android-nestedscrollview

11
推荐指数
1
解决办法
2253
查看次数