recyclerview嵌套在NestedScrollView里,一次性加载出全部数据问题。 因为要实现向上滑动时toolbar悬停在顶部的那种效果,所以recyclerview必须嵌套在NestedScrollView里。 作者给出的两种解决方法: 1.将嵌套部分的布局当作头部和尾部添加到rv上面或下面,去除ScrollView。 2.更换第三发的嵌套的上拉下拉控件。 第一种直接不可取,第二种就是要抛弃这个开源库的意思^_^ 同时这个问题可以参考已关闭的issues #1821
Activity
AngelBo commentedon Jan 25, 2018
@chailijun 可以的
public class MainActivity extends AppCompatActivity implements BaseQuickAdapter.RequestLoadMoreListener, SwipeRefreshLayout.OnRefreshListener {
private final String TAG = "MainActivity";
private RecyclerView recyclerView;
private NestedScrollView scrollView;
private SwipeRefreshLayout swipe;
// testAdapter.setOnLoadMoreListener(this,recyclerView);
recyclerView.setAdapter(testAdapter);
}
}
activity_main.xml
<android.support.constraint.ConstraintLayout 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:background="#fff"
tools:context="com.test.netrec.MainActivity">
</android.support.constraint.ConstraintLayout>
footer.xml
item.xml
AngelBo commentedon Jan 25, 2018
Ryan2Archibald commentedon Mar 3, 2018
感谢楼上的写法,亲测可行。如果必须用ScrollView又不想用别的框架,可以使用楼上的写法来
Zane1024 commentedon Dec 25, 2019
非常感谢 AngelBo 解决了我APP首页问题
yxmFromTheMoon commentedon Mar 20, 2020
这样虽然是可以,但是我滑动到第四页之后就开始有了明显的卡顿现象,大神求教怎么解决这个问题