我正在使用分页库来加载数据并填充我的recyclerview,它位于nestedscrollview中。但是问题在于,分页自动工作直到从API获取所有数据为止。我知道这是由于nestedscrollview引起的。但不幸的是,我的布局需要scrollview,因为在此片段中除了recyclerview还有一个顶部部分。
这是我的布局:
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
>
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
//have a layout here which scrolls with recyclerview
<Recyclerview />
</ConstraintLayout>
</NestedScrollView>
如果不使用嵌套滚动视图,一切都正常。在googlesamples git仓库中有一个关于这个问题的未解决问题。
https://github.com/googlesamples/android-architecture-components/issues/215
如果RecyclerView在带有Android Jetpack分页库的ScrollView中,有没有人有想法如何实现分页?我知道我们可以使用传统类型的分页将侦听器附加到NestedScrollView上,但我正在寻找使用Architecture Component库实现分页的方法。 https://developer.android.com/topic/libraries/architecture/paging/