是否有任何类结合了 ScaleGestureDetector 和 GestureDetector 的功能?
大家好,
是否有任何类结合了 ScaleGestureDetector 和 GestureDetector 的功能? 我正在使用下面的 onTouchEvent 代码,但只有一个手势类正在运行。如果我想使用 GestureDetector 以及 ScaleGestureDetector 的所有功能,
@Override
public boolean onTouchEvent(MotionEvent ev)
{
if (mScaleDetector.onTouchEvent(ev))
return true;
else if (mGestureDetector.onTouchEvent(ev))
return true;
else
return false;}
其中 mScaleDetector 是 ScaleGestureDetector,mGestureDetector 是 GestureDetector
提前感谢
Hi to all,
Is there any class which have combined functionality of ScaleGestureDetector and GestureDetector ?
I am using below code for onTouchEvent but only one gesture class is running. If I want to use all the functions of GestureDetector as well as ScaleGestureDetector
@Override
public boolean onTouchEvent(MotionEvent ev)
{
if (mScaleDetector.onTouchEvent(ev))
return true;
else if (mGestureDetector.onTouchEvent(ev))
return true;
else
return false;}
where mScaleDetector is ScaleGestureDetector and mGestureDetector is GestureDetector
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对我来说,做类似的事情
似乎有用。解释可能是,当您在它们之间执行布尔值 and 时,它将处理这两个方法以获得要返回的结果。
您的方法的问题可能是当手势方法之一消耗事件时您可能忘记返回 true。
希望这有帮助,
米哈伊
For me doing something like
seems to work. The explanation may be that when you do a boolean and between them, it will process both methods in order to obtain the result to be returned.
The issue with your approach may be that you perhaps forgot to return true when one of the gesture methods consumed the event.
Hope this helps,
Mihai
您应该始终将
onTouchEvent
参数传递给两个检测器,否则手势检测可能会失控。请参阅文档中的示例。
You should always pass
onTouchEvent
parameter to both detectors, otherwise gesture detection may go haywire.See example in documentation.