• 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;
     }

  • 相关阅读:
    运算符
    练习
    JAVA学习日报 9/23
    JAVA学习日报 8.22
    JAVA学习日报 8.21
    第一节:SpringMVC 处理请求数据【1】
    第六节:@RequestMapping 映射请求占位符 @PathVariable 注解
    第一节:REST 风格的URL地址约束
    第二节:REST风格的案例及源码分析
    (一)IOC 容器:【1】@Configuration&@Bean 给容器中注册组件
  • 原文地址:https://www.cnblogs.com/anskya520/p/3479131.html
Copyright © 2020-2023  润新知