I need to disable swiping to open/close SlidingPaneLayout because my main view is a map. I\'ll open/close it using a button.
This one is a bit tricky. If you always return true in onInterceptTouchEvent()
it will dispatch event to the hidden content below. I was able to achieve it like this:
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
return !slidingEnabled || super.onInterceptTouchEvent(ev);
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
if (!slidingEnabled) {
// Careful here, view might be null
getChildAt(1).dispatchTouchEvent(ev);
return true;
}
return super.onTouchEvent(ev);
}