如何检测在一个ImageView的第二个手指触摸? [英] How to detect the second finger touch on an ImageView?

查看:142
本文介绍了如何检测在一个ImageView的第二个手指触摸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何可以检测多点触控事件?在code我尝试是:

How can I detect multitouch events? The code im trying is:

ImageView im = (ImageView) findViewById(R.id.imageView1);
im.setOnTouchListener(new OnTouchListener() {
  @Override
  public boolean onTouch(View v, MotionEvent event) {
    switch (event.getAction() & MotionEvent.ACTION_MASK) {
      case MotionEvent.ACTION_POINTER_DOWN:
        Log.e("case MotionEvent.ACTION_POINTER_DOWN","case MotionEvent.ACTION_POINTER_DOWN");
        break;
      case MotionEvent.ACTION_DOWN:
        Log.e("case MotionEvent.ACTION_DOWN","case MotionEvent.ACTION_DOWN");
        break;
      case MotionEvent.ACTION_UP:
        Log.e("case MotionEvent.ACTION_UP","case MotionEvent.ACTION_UP");
        break;
      case MotionEvent.ACTION_MOVE:
        Log.e("case MotionEvent.ACTION_MOVE","case MotionEvent.ACTION_MOVE");
        break;
    }
    return false;
  }
});

有检测第一触摸和在日志猫的输出为MotionEvent.ACTION_POINTER_DOWN。如何知道第二触摸是否发生?

It detects the first touch and the output in the log cat is MotionEvent.ACTION_POINTER_DOWN. How to know whether a second touch has taken place?

推荐答案

有很多方法可以做到这一点,所以你可以选择很多,这里的一些环节有写一个完整的应用程序来处理多点触摸。一​​个

There are many ways to do it, so u can choose one of many here some link have write a complete application to handle multi touch.

多点触控

多触摸处理

这篇关于如何检测在一个ImageView的第二个手指触摸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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