手势
android提供的两种手势:1.android提供了手势检测,并未手势检测提供了相应的监听器
2.android允许开发者添加手势,并提供了相应的API识别用户手势
手势检测:手势检测器类:GestureDetector
监听器:OnGestureListener,负责对用户的手势行为提供响应
事件处理方法:boolean OnDown(MotionEvent e):当触摸事件按下时触发该方法
boolean onFing(MotionEvent e1,MotionEvent e1,float velocityX,float velocityY)
当用户在触摸屏上“拖过”是触发该方法,其中velocityX,velocityY代表“拖过”动作在横
向,纵向上的速度
abstract void onLongPress(MotionEvent e):当用户在屏幕上长按时触发该方法
onScroll(MotionEvent e1,MotionEvent e2,float distanceX,float distanceY)
当用户在屏幕上“滚动”时触发该方法
void onShowPress(MontionEvent e):当用户在触摸屏上按下,而且还未移动和松开
时触发该方法
boolean onSingleTapUp(MontionEvent e):用户在触摸屏上的轻击事件将会触发
andorid手机检测步骤:第一步:创建一个GestureDetector对象,创建该对象时必须实现以个GestureDete
ctor.OnGestureListener监听器实例
第二步:为应用程序Activity的TouchEvent事件绑定监听器,在事件处理中指定
Activity上的TouchEvent事件交给GestureDetector处理