我试图找出使图像旋转的最佳方法,用户的手指向左或向右拖动,以及旋转角度.
float x1 = lastEvent[0] - lastEvent[1];float y1 = lastEvent[2] - lastEvent[3]; float degrees1 = (float)(Math.atan2(y1, x1)); float x2 = event.getX(0) - event.getX(1);float y2 = event.getY(0) - event.getY(1);float degrees2 = (float)(Math.atan2(y2, x2)); float degrees = (float) Math.todegrees(degrees2-degrees1);
但它不像我想要的那样旋转..是否有任何旋转手势的倾听者?谢谢
解决方法:
/** Determine the degree between the first two fingers */ private float rotation(MotionEvent event) { double delta_x = (event.getX(0) - event.getX(1)); double delta_y = (event.getY(0) - event.getY(1)); double radians = Math.atan2(delta_y, delta_x); if (Constant.TRACE) Log.d("Rotation ~~~~~~~~~~~~~~~~~", delta_x+" ## "+delta_y+" ## "+radians+" ## " +Math.todegrees(radians)); return (float) Math.todegrees(radians); }
总结 以上是内存溢出为你收集整理的Android中的2个手指旋转手势监听器全部内容,希望文章能够帮你解决Android中的2个手指旋转手势监听器所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)