【问题标题】:Get intermediate coordinates获取中间坐标
【发布时间】:2013-11-15 03:16:20
【问题描述】:

我有一个从 SimpleOnGestureListener 扩展的类,在那个类中我有一个方法: 公共布尔 onFling(MotionEvent e1,MotionEvent e2,浮动速度 X,浮动速度 Y)。

现在我可以得到 e1 和 e2 坐标,我可以检查它是什么类型的手势,但是否也可以得到中间坐标?

【问题讨论】:

  • 我想会是:MotionEvent ic = e1 + e2 /2;
  • MotionEvent 的 + 和 / 运算符未定义。但它如何给我中间坐标?如我所见,这给出了一个 X 和 Y?

标签: android swipe gestures


【解决方案1】:

自己找到的:

    View testview = (View) findViewById(R.id.testView);

        // Set the touch listener for the main view to be our custom gesture listener
        testview.setOnTouchListener(new View.OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
                if(event.getAction() == MotionEvent.ACTION_MOVE)
                {
                    Log.d("Gestures","Moving...");
                }
            }

【讨论】:

    猜你喜欢
    • 2016-05-10
    • 2022-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-05
    • 1970-01-01
    • 2015-11-03
    • 2010-12-03
    相关资源
    最近更新 更多