(都是竖向)
1. recyclerview千万不要height=“wrap_content”
相当于recyclerview回收失效,数据量多的情况下内存爆炸
需要onMeasure时自己算高度
2. recyclerview的scrollY一直为0,且canScrollVertically(dy)一直为true
改用
// dy>0时
(rv?.layoutManager as? LinearLayoutManager)?.findLastCompletelyVisibleItemPosition() != (rv?.adapter?.itemCount ?: 0) - 1
// dy<0时
(rv.layoutManager as? LinearLayoutManager)?.findFirstCompletelyVisibleItemPosition() == 0
来判断
3. fling失效
网上都说android:nestedScrollingEnabled=“false”(是不是离谱了点)
一般都是因为其他坑导致哪里算错了,这里建议用NestedScrollingParent3/Child3,因为2代fling有一些问题,详见
https://blog.csdn.net/mehmetkollayan/article/details/119941567
https://juejin.cn/post/6844904184911773709#heading-17
4. 反驳👆2
如果rv的第一个或者最后一个item正好不可见,则2.方法无效!
canScrollVertically也无效
5. 在onNestedScroll里想滚child,要先disable child,滚完再enable。。不然会嵌套
如果target view不在滚出了屏幕,fling就会停止