Problem description:
Sliding events conflict between ViewPager and SlidingPaneLayout.
Problem analysis:
SlidingPaneLayout blocks the ViewPager's sliding event when the finger slides left and right.
Solution:
Customize SlidingPaneLayout class
import ; import .; import .; import ; import ; import ; public class PagerEnabledSlidingPaneLayout extends SlidingPaneLayout { private float mInitialMotionX; private float mInitialMotionY; private float mEdgeSlop; public PagerEnabledSlidingPaneLayout(Context context) { this(context, null); } public PagerEnabledSlidingPaneLayout(Context context, AttributeSet attrs) { this(context, attrs, 0); } public PagerEnabledSlidingPaneLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); ViewConfiguration config = (context); mEdgeSlop = (); } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { switch ((ev)) { case MotionEvent.ACTION_DOWN: { mInitialMotionX = (); mInitialMotionY = (); break; } case MotionEvent.ACTION_MOVE: { final float x = (); final float y = (); if (mInitialMotionX > mEdgeSlop && !isOpen() && canScroll(this, false, (x - mInitialMotionX), (x), (y))) { MotionEvent cancelEvent = (ev); (MotionEvent.ACTION_CANCEL); return (cancelEvent); } } } return (ev); } }
The above article on the sliding event conflict resolution of ViewPager and SlidingPaneLayout is all the content I share with you. I hope you can give you a reference and I hope you can support me more.