onDoubleTap 监听器和 onDoubleTapEvent 监听器有什么区别

What is the difference between onDoubleTap listener and onDoubleTapEvent listener

我是 Android 的新手,最近学习了手势!

这两种方法有什么区别?

@Override
public boolean onDoubleTap(MotionEvent e) {
    return false;
}

还有这个

@Override
public boolean onDoubleTapEvent(MotionEvent e) {
    return false;
}

他们似乎在做同样的事情。你用的是哪一种,有什么区别

简单的答案是

 boolean onDoubleTap (MotionEvent e) - 

发生双击时通知。

双击时可以通知 而param motionEvent是针对第一次点击的down motion事件。

  boolean onDoubleTapEvent (MotionEvent e)` -

双击手势中的事件发生时通知

您可以在双击手势发生时通知事件,包括 downmoveup 事件,并且参数 motionEvent 用于运动事件

因此使用 doubleTapEvent 您可以获得额外的标签手势以及点击

看看 --> 这可能对您的触摸手势有帮助

进一步尝试了解此示例中发生的情况

//initialize the Gesture Detector  
        gd = new GestureDetector(this);  

        //set the on Double tap listener  
        gd.setOnDoubleTapListener(new OnDoubleTapListener()  
        {  
            @Override  
            public boolean onDoubleTap(MotionEvent e)  
            {  
                //set text color to green  
                tvTap.setTextColor(0xff00ff00);  
                //print a confirmation message  
                tvTap.setText("The screen has been double tapped.");  
                return false;  
            }  

            @Override  
            public boolean onDoubleTapEvent(MotionEvent e)  
            {  
                //if the second tap hadn't been released and it's being moved  
                if(e.getAction() == MotionEvent.ACTION_MOVE)  
                {  
                    //set text to blue  
                    tvTapEvent.setTextColor(0xff0000ff);  
                    //print a confirmation message and the position  
                    tvTapEvent.setText("Double tap with movement. Position:\n"  
                            + "X:" + Float.toString(e.getRawX()) +  
                            "\nY: " + Float.toString(e.getRawY()));  
                }  
                else if(e.getAction() == MotionEvent.ACTION_UP)//user released the screen  
                {  
                    tvTapEvent.setText("");  
                }  
                return false;  
            }  

            @Override  
            public boolean onSingleTapConfirmed(MotionEvent e)  
            {  
                //set text color to red  
                tvTap.setTextColor(0xffff0000);  
                //print a confirmation message and the tap position  
                tvTap.setText("Double tap failed. Please try again.");  
                return false;  
            }  
        });