Android手势识别02——旋转、移动等使用第三方库

Android手势识别02——旋转、移动等使用第三方库


一、简要说明

通过前面一篇文章(Android手势识别01——基本手势的处理)的学习,我们知道了基本手势的使用方法。但是我们发现这里基本上手势的使用方法中,竟然没有旋转这种手势,是不是很不可思议呢?当然你也可以自己来写这种手势,其实有现成的手势库可以用了哦? 那么我们就来用用这个库

android-gesture-detectors

我们可以看看这个库的说明:

1.1 Containments


RotateGestureDetector

Helps finding out the rotation angle between the line of two fingers (with the
normal or previous finger positions)

MoveGestureDetector

Convenience gesture detector to keep it easy moving an object around with one
ore more fingers without losing the clean usage of the gesture detector pattern.

ShoveGestureDetector

Detects a vertical two-finger shove. (If you place two fingers on screen with less than a 20 degree angle between them,
this will detact movement on the Y-axis.)

ScaleGestureDetector (default Android)

This one is NOT in this framework, but is gesture detector that resides in the
Android API since API level 8 (2.2).

BaseGestureDetector (abstract)

Abstract class that every new gesture detector class should extend.

TwoFingerGestureDetector (abstract)

Abstract class that extends the BaseGestureDetector and that every new gesture
detector class for two finger operations should extend.


1.2 库的使用方式简要说明

这个库的使用方式和 Android原生库的使用方式一模一样。

1.创建监听的实例
2.创建手势探测器
3.重写onTouchEvent方法,这个这个方法内调用探测器的onTouchEvent()


二、RotateGestureDetector的使用

2.1 RotateGestureDetector和RotateGestureDetector.SimpleOnRotateGestureListener的简要说明

RotateGestureDetector 用处创建旋转手势的探测器。其中 getRotationDegreesDelta() 用户获取旋转的角度(单位:角度),值为一个相对值,相对与上一次旋转的角度值,即以上一次为起点。

RotateGestureDetector.SimpleOnRotateGestureListener 用于创建堂测器的监听。有三个事件


                
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值