Android的,禁止刷卡与SlidingPaneLayout互动 [英] Android, disable the swiping to interact with SlidingPaneLayout

查看:162
本文介绍了Android的,禁止刷卡与SlidingPaneLayout互动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要禁用刷卡打开/关闭SlidingPaneLayout,因为我的主要观点是一张地图。 我会打开/关闭它使用一个按钮。

I need to disable swiping to open/close SlidingPaneLayout because my main view is a map. I'll open/close it using a button.

推荐答案

子类 SlidingPaneLayout ,覆盖 onInterceptTouchEvent()并使其总是返回。这将prevent SlidingPaneLayout 从处理触摸事件。

Subclass SlidingPaneLayout, override onInterceptTouchEvent() and make it always return false. This will prevent SlidingPaneLayout from handling touch events.

请参阅 http://developer.android.com/training/gestures/viewgroup.html 了解更多信息。

更新
如果触摸事件不是由子视图(S)处理,在 SlidingPaneLayout 的onTouchEvent()方法将不过叫。要完全禁用处理触摸事件还覆盖的onTouchEvent()和总是返回

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.

这篇关于Android的,禁止刷卡与SlidingPaneLayout互动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆