(1)使用PagingDataAdapter
class MyAdapter : PagingDataAdapter(MyDataComparator) {
override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
getItem(position)?.let { myData ->
holder.bind(myData)
}
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
return MyViewHolder.create(parent)
}
}
(2)禁用嵌套滚动视图功能
val recyclerView = findViewById(R.id.recycler_view)
recyclerView.layoutManager = LinearLayoutManager(this)
recyclerView.isNestedScrollingEnabled = false
(3)使用NestedScrollView(不推荐使用)