简体   繁体   中英

Rotating an image around a point by touching and dragging it till the point we want to rotate it

Actually what I want to do is I have a Bitmap image I'm using SurfaceView instead of View to draw and using onDraw function to draw the image.

What I want to do is I have an image a pointer with arrow (like a needle we have in multimeter) I want the user to touch the tip of the arrow and rotate if by holding n dragging till the point he wants to rotate it to. ie if arrow is straight then 90 degree on either side we can rotate.

I found few examples on this site and internet but non of them were precise or explained anything and were hard to understand.

If someone can help me with this I would be very grateful.

You have two things to do. Detect the touch and then rotate the image.

For the touch stuff you need to use an onTouchListener there are plenty of questions about draging which is the same basic code try this one

Somthing that may help with the rotate here You basicaly use a Matrix and use it to transform a bitmap .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM