zoukankan      html  css  js  c++  java
  • 2点触摸事件

     private boolean isZoom = false;
     private float oldDist;
        private float spacing(MotionEvent event) {
            float x = event.getX(0) - event.getX(1);
            float y = event.getY(0) - event.getY(1);
            return FloatMath.sqrt(x * x + y * y);
        }
     
     @Override
     public boolean onTouchEvent(MotionEvent event) {
      super.onTouchEvent(event);
      getCurrentInfo();
      
            switch (event.getAction() & MotionEvent.ACTION_MASK) {
            case MotionEvent.ACTION_DOWN:
                break;
            case MotionEvent.ACTION_POINTER_UP:
                isZoom = false;
                break;
            case MotionEvent.ACTION_POINTER_DOWN:
                oldDist = spacing(event);
                isZoom = true;
                break;
            case MotionEvent.ACTION_MOVE:
                if (isZoom) {
                    float newDist = spacing(event);

                    if (newDist + 10 > oldDist) {
               MapUtil.MapzoomIn();
               setMainMapScale();
                    }

                    if (newDist + 10 < oldDist) {
               MapUtil.MapzoomOut();
               setMainMapScale();
                    }
                }

                break;
            }
      
      return false;
     }

  • 相关阅读:
    DECLARE
    deallocvt
    科研院所
    jQuery Ajax 确定 form 表单 submit 提交成功
    Java实现 LeetCode 10 正则表达式匹配
    Java实现 LeetCode 10 正则表达式匹配
    Java实现 LeetCode 9 回文数
    Java实现 LeetCode 9 回文数
    Java实现 LeetCode 9 回文数
    Java实现 LeetCode 8 字符串转换整数(atoi)
  • 原文地址:https://www.cnblogs.com/anskya520/p/3479131.html
Copyright © 2011-2022 走看看