【发布时间】:2016-05-06 13:13:21
【问题描述】:
我在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>
Recyclerview 有 OnScrollListener 处理从这个例子中获取的无限滚动:https://guides.codepath.com/android/Endless-Scrolling-with-AdapterViews-and-RecyclerView。但是,似乎nestedscrollview 正在触发 onScrolled 方法,因此会立即加载整个项目列表。
问题: 我怎样才能防止这种行为?
注意,一切都与不在nestedscrollview 中的recyclerview 完美配合
【问题讨论】:
-
你有没有机会让它工作?
-
很遗憾,我没有足够的时间来全面调查此问题。快速的想法,尝试在使用 OnGlobalLayoutListener 处理所有视图后添加滚动监听器
-
我所做的是将所有内容作为标题视图放在回收器视图适配器中,以便顶视图与回收器视图一起滚动
标签: android android-recyclerview endlessscroll android-nestedscrollview