美文网首页
SwipeRefreshLayout 与 横划事件冲突

SwipeRefreshLayout 与 横划事件冲突

作者: 总是说下次 | 来源:发表于2016-05-18 11:47 被阅读374次

    原因是在有横划view 执行onInterceptTouchEvent 动作为scrollFling时候一般会调用getParent().requestDisallowInterceptTouchEvent(true);来阻止父件的滚动,而在SwipeRefreshLayout重写了该方法

     @Override
        public void requestDisallowInterceptTouchEvent(boolean b) {
            // if this is a List < L or another view that doesn't support nested
            // scrolling, ignore this request so that the vertical scroll event
            // isn't stolen
            if ((android.os.Build.VERSION.SDK_INT < 21 && mTarget instanceof AbsListView)
                    || (mTarget != null && !ViewCompat.isNestedScrollingEnabled(mTarget))) {
                // Nope.
            } else {
                super.requestDisallowInterceptTouchEvent(b);
            }
        }
    

    mTarget是SwipeRefreshLayout的直接子View。解决办法是直接子View能嵌套滚动.满足ViewCompat.isNestedScrollingEnabled(mTarget)

    相关文章

      网友评论

          本文标题:SwipeRefreshLayout 与 横划事件冲突

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