禁用或prevent多点触控的活动 [英] Disable or prevent multitouch in Activity

查看:140
本文介绍了禁用或prevent多点触控的活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对其中一个用户希望能够快速触摸连续的活动若干意见,我使用的是 TouchListener 和处理 MotionEvent捕获这些风格。 ACTION_DOWN 。然而,如果用户使用两只手,这是非常可能的是,下一个视图将'Touch'ed之前使用者拉previous手指。在这种情况下,一个 MotionEvent.ACTION_MOVE 被解雇的第一个视图,而不是期望的 MotionEvent.ACTION_DOWN 第二视图。

I have several Views on an Activity which a user wants to touch quickly in succession and I capture these touches using a TouchListener and handling MotionEvent.ACTION_DOWN. However, if the user is using two hands, it's very likely that the next View will be 'Touch'ed before the user pulls the previous finger up. In this scenario, a MotionEvent.ACTION_MOVE is fired for the first view rather than the desired MotionEvent.ACTION_DOWN for the second view.

有没有什么办法来解决或prevent这种行为?我试过调度新事件 MotionEvent.ACTION_UP ,也删除了事件侦听器,但既不似乎工作。

Is there any way to work around or prevent this behavior? I've tried dispatching a new event with MotionEvent.ACTION_UP and also removing the event listener but neither seem to work.

推荐答案

要解决这种情况下,最好的办法是使用的ViewGroup 和实施 onInterceptTouchEvent 方法来手动路线,你认为合适的触摸事件。

The best way to work around this scenario is to use a ViewGroup and implement the onInterceptTouchEvent method to manually route the touch events as you see fit.

这原本是在这里找到答案: Android的多点触控!砍谁了?

This was originally answered here: Android multitouch! hack anyone?

code实施此解决方案(在回答上述问题的评论部分中)在这里找到: http://pastebin.com/hiE1aTCw

Code implementing this solution (found in the comments section of the answer to the above question) is found here: http://pastebin.com/hiE1aTCw

这篇关于禁用或prevent多点触控的活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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