I need to disable swiping to open/close SlidingPaneLayout because my main view is a map. I'll open/close it using a button.
Subclass SlidingPaneLayout
, override onInterceptTouchEvent()
and make it always return false
. This will prevent SlidingPaneLayout
from handling touch events.
See http://developer.android.com/training/gestures/viewgroup.html for more information.
Update:
If touch events are not handled by the child view(s), the SlidingPaneLayout
's onTouchEvent()
method will be called nevertheless. To completely disable handling touch events also override onTouchEvent()
and always return false
.
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
return false;
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
return false;
}
Note: The downside of this approach is that touch events still get dispatched to the second child view when it's only partly visible. So you might want to check out the other answers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With