GestureDetector-手势

手势(GestureDetector类)

//手势监听GestureDetector.OnGestureListener
  • boolean onDown(MotionEvent e),按下事件
  • boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY),在屏幕上拖动,e1与e2为拖动前后的位置,veloctiyX/Y表示拖动在横向与纵向的速度
  • abstract void onLongPress(MotionEvent e),长按屏幕触发该事件
//使用手势监听类处理手势
//创建GestureDetector类
GestureDetector detector=new GestureDetector(this,this);
//将Acitivity上的触碰事件交给GestureDetector处理
public boolean onTouchEvent(MotionEvent me){
    //将事件交给GestureDetector处理,完成此步操作,重写onDown(),onFling()等方法即可由GestureDetector处理
    return detector.onTouchEvent(me);
}



//自定义手势
//使用GestureLibraies方法加载手势库
  • static GestureLibrary fromFile(String path),从path路径文件加载手势库
  • static GestureLibrary fromFile(File path),从path文件加载手势库
  • static GestureLibrary fromPrivateFile(Context context,String name),从指定应用程序数据路径文件name中加载手势库
  • static GestureLibrary fromRawResource(Context context,int resourceid),从resourceid代表的资源中加载手势库
//添加手势API
  • void addGesture(String entryName,Gesture gesture),添加一个名为entryName的手势
  • ArrayList<Gesture> getGestures(String entryName),获取名为entryName的所有手势
  • ArrayList<Prediction> recognize(Gesture gesture),从当前手势库识别与gesture匹配的全部手势
  • void removeGesture(String entryName,Gesture gesture),删除名为entryName的手势
  • boolean save(),添加手势或删除手势后保存手势库
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值