美文网首页
解决recyclerview滑动冲突,修复CollapsingT

解决recyclerview滑动冲突,修复CollapsingT

作者: 程序员大耳 | 来源:发表于2021-05-25 11:35 被阅读0次

场景:

布局xml有个CollapsingToolbarLayout,竖向滑动recycleview包裹多个子item是横向滑动recycleview。

滑动冲突,子item是横向滑动recycleview,它可以横向滑动,会把事件消费掉.这样CollapsingToolbarLayout就不会响应折叠.大的recyclerview不会出现滑动.

解决方案:

/**

* Enable nested scrolling.

*

* <p>This is a delegate method. Call it from your {@link android.view.View View} subclass

* method/{@link android.support.v4.view.NestedScrollingChild} interface method with the same

* signature to implement the standard policy.</p>

*

* @param enabled true to enable nested scrolling dispatch from this view, false otherwise

*/

public void setNestedScrollingEnabled(boolean enabled) {

    if (mIsNestedScrollingEnabled) {

        ViewCompat.stopNestedScroll(mView);

    }

    mIsNestedScrollingEnabled = enabled;

}

大意:启用嵌套滚动,参数启用为true以从此视图启用嵌套滚动调度,否则为false

内部嵌套的recyclerview调用setNestedScrollingEnabled(false);

就可以解决了.

相关文章

网友评论

      本文标题:解决recyclerview滑动冲突,修复CollapsingT

      本文链接:https://www.haomeiwen.com/subject/bkbqsltx.html