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
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: