CymChad / CymChad/BaseRecyclerViewAdapterHelper
嵌套滑动问题
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 24.6k
- Forks
- 5.2k
- PR merge metrics
- No merged PRs in 30d
Description
因为项目需要,处理嵌套滑动问题,我首先参考了这个https://www.jianshu.com/p/c5ccf0c38186
首先使用方案三,发现没有效果,于是改用方案一,然后发现在普通列表项滑动正常,但是如果父级recycleview设置了headview,则在其headview中滑动没有任何效果,所以我猜想是headview惹的祸(footview没有测试),于是又参考了https://blog.csdn.net/qq_28844947/article/details/107069106
最终解决方案如下:
继承RecyclerView,重写onInterceptTouchEvent方法如下:
public boolean onInterceptTouchEvent(MotionEvent e) {
Adapter adapter = getAdapter();
View headView=null;
if(adapter instanceof BaseQuickAdapter){
BaseQuickAdapter baseQuickAdapter= (BaseQuickAdapter) adapter;
if(baseQuickAdapter.hasHeaderLayout()){
headView=baseQuickAdapter.getHeaderLayout();
}
}else if(adapter instanceof DelegateMultiAdapter){
DelegateMultiAdapter delegateMultiAdapter= (DelegateMultiAdapter) adapter;
headView=delegateMultiAdapter.getHeaderLayout();
}
View view = findChildViewUnder(e.getX(), e.getY());
if(view.equals(headView)){
return super.onInterceptTouchEvent(e);
}else{
return false;
}
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at RecyclerView.onInterceptTouchEvent and inspect how BaseQuickAdapter and DelegateMultiAdapter expose header layouts. Reproduce nested scrolling with a parent RecyclerView header, then verify that scrolling works both inside the header and in ordinary list items.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100