GenericMotion - 向下动作不触发

GenericMotion - Action Down not firing

我想跟踪手指从触摸我的 ImageView 开始的整个运动。我发现 GenericMotion 事件应该是正确的使用方法。

我应该做什么(或避免)以在 GenericMotion 事件中执行向下、移动和向上操作?我只得到 HoverEnter、HoverMove 和 HoverExit 操作,即使我从触摸 ImageView 的中心开始也是如此。

Android: OnTouch, MotionEvent.ACTION_MOVE is not recognized?

这里我了解到,如果不处理Down动作,我就无法得到剩余的动作,但是我没有得到Down动作!

private void OnPlayerInfoRatingGenericMotion(object sender, View.GenericMotionEventArgs e)
{
    //goes here only with hover actions
    if (e.Event.Action==MotionEventActions.Down)
    {
        //never goes here
    }
    if (e.Event.Action==MotionEventActions.Move)
    {
        //never goes here
    }
}

我做错了什么?

GenericMotion 无法检测到您手指的手势。我认为它仅用于报告运动事件。可以参考这里的document

例如,您可以将图像视图从上到下移动,然后 GenericMotion 可以检测到 "move" 动作。

如果你想检测你的手指事件我想你可以实现OnTouchListener

例如:

imgview.SetOnTouchListener(new MyTouchListener());

实现MyTouchListener:

public class MyTouchListener: Java.Lang.Object, View.IOnTouchListener
{
    public bool OnTouch(View v, MotionEvent e)
    {
        throw new NotImplementedException();
    }

    public bool OnTouchEvent(View v, MotionEvent e)
    {
        if (e.Action == MotionEventActions.Down)
        {
            Log.Debug("Mike", "Down");
            Console.WriteLine("Down");
            return true;
        }
        if (e.Action == MotionEventActions.Up)
        {
            Log.Debug("Mike", "Up");
            Console.WriteLine("Up");
            return true;
        }
        if (e.Action == MotionEventActions.Move)
        {
            Log.Debug("Mike", "Move");
            Console.WriteLine("Move");
            return true;
        }

        return false;
    }
}

还可以实现IOnGestureListener检测手势。