开发者

Is there any class which have combined functionality of ScaleGestureDetector and 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
            retu开发者_JAVA技巧rn false;}

where mScaleDetector is ScaleGestureDetector and mGestureDetector is GestureDetector


thanks in advance


For me doing something like

return mScaleDetector.onTouchEvent() && mGestureDetector.onTouchEvent(ev);

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


You should always pass onTouchEvent parameter to both detectors, otherwise gesture detection may go haywire.

See example in documentation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜