GenericMotion - 动作向下不触发 [英] GenericMotion - Action Down not firing

查看:159
本文介绍了GenericMotion - 动作向下不触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想追踪通过触摸我的ImageView开始的手指的整个动作。我发现GenericMotion事件应该是正确使用的。

I want to trace the whole movement of a finger that started by touching my ImageView. I found that GenericMotion event should be the correct one to use.

我应该做什么(或避免)在GenericMotion事件中执行Actions Down,Move和Up ?我只接触HoverEnter,HoverMove和HoverExit动作,即使我开始触摸我的ImageView中心。

What am I supposed to do (or to avoid) to get Actions Down, Move and Up in GenericMotion event? I get only HoverEnter, HoverMove and HoverExit actions, even if I start with touching the center of my ImageView.

Android:OnTouch,MotionEvent.ACTION_MOVE无法识别?

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

Here I learned that without handling Down action I can't get the remaining actions, but I don't get the Down action!

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 无法检测到gestu你的手指。我认为它仅用于报告移动事件。您可以参考文件这里。

GenericMotion can not detect the gesture of your finger. I think it is only used to report for movement event. You can refer to the document here.

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

For example , You can move your imageview from top to bottom then the GenericMotion can detect the "move" action.

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

If you want to detect your finger event I think you can achieve OnTouchListener.

例如:

imgview.SetOnTouchListener(new MyTouchListener());

实现MyTouchListener:

achieve 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 检测你的手势。

Also you can achieve IOnGestureListener to detect your gesture.

这篇关于GenericMotion - 动作向下不触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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