Android中的2手指旋转手势监听器
我试图找出使图像随着用户手指向左或向右拖动以及旋转角度而旋转的最佳方法。
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);
但它没有像我想要的那样旋转。有旋转手势的侦听器吗?谢谢
I'm trying to figure out the best way to make an image rotate along with a user's finger dragging it left or right, and the angle of rotation.
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);
But it doesn't rotate like i want it.. Is there any listener for rotation gesture? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您正在寻找很好的解释,这个链接非常有用。
通过使用此库,您可以创建一个包并将 SandboxView、TouchManager 和 Vector2D 类复制/粘贴到该包中。
然后,将 FrameLayout 添加到您的 xml 文件中(而不是 imageView)并将其链接到您的代码。
最后,使用以下代码将位图添加到布局中:
This link is very useful if you are looking a good explanation.
By Using this library, you can create a package and copy/past SandboxView, TouchManager and Vector2D classes into that package.
Then, add FrameLayout into your xml file (instead of imageView) and link it to your code.
Finally, add bitmap to the layout by using following code: