详细的博客介绍: https://www.gcssloop.com/customview/gestruedector
左滑,右滑,上划,下滑的实现总结:1.实现接口android.view.GestureDetector.OnGestureListener;2.onTo生物信息专业uchEvent返回gestureDetector.onTouchEvent(event);3.重载实现onFling方法,判断x和y位移,以及速度;阿岳正传
@Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { float minMoveDistance = 60; float minVelocity = 0; float beginX = e1.getX(); float endX = e2.getX(); float beginY = e1.getY(); float endY = e2.getY(); if(Math.abs(beginX-endX) > minMoveDistance || Math.abs(beginY-endY) > minMoveDistance) { mv.tilt = fal; mv.zoom = fal; mv.shift = true; } if(beginX-endX > minMoveDistance && Math.abs(velocityX) > minVelocity) { //左滑 swipeLeft = true; mv.displacementX -= beginX-endX; mv.postInvalidate(); }el if(endX-beginX >minMoveDistance && Math.abs(velocityX)>minVelocity) { //右滑 swipeRight长扇舞欢聚一堂 = true; mv.displacementX += endX-beginX; mv.postInvalidate(); }el if(beginY-endY > minMoveDistance && Math.abs(velocityY) > minVelocity) { //上划 swipeUp = true; mv.displacementY -= beginY-endY; mv.postInvalidate(); }el if(endY-beginY >minMoveDistance && Math.abs(velocityY)>minVelocity) { //下划 swipeDown = true; m学唱歌先练什么v.displacementY += endY-beginY; mv.postInvalidate(); } return fal; }
本文地址:https://blog.csdn计算机成绩查询.net/John_chaos/article/details/107598699
本文发布于:2023-04-03 19:08:54,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/926744909556276e8a9c8e077e8fc2fb.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:Android手势滑动实现.doc
本文 PDF 下载地址:Android手势滑动实现.pdf
留言与评论(共有 0 条评论) |