Android, help rotating image on touch

后端 未结 3 1262
情书的邮戳
情书的邮戳 2021-01-31 23:43

I am trying to rotate one of the transparent PNGs on this image. The number part is what I want to rotate. I am able to do this, but it is not what I am trying to achieve

3条回答
  •  青春惊慌失措
    2021-02-01 00:25

    I presume you want to rotate an image at the point where a user touches the screen? If so, extend the SimpleOnGestureListener like this example:

    public class MyGestureDetector extends SimpleOnGestureListener
    {  
         @Override
         public void onLongPress(MotionEvent event)
         {
             int X = (int)event.getX();          
             int Y = (int)event.getY();
    
             ...Rotate the image
         }
    }
    

    Once you've got the screen coordinates of the touch event, you could apply a Rotation Animation about the point - see here for more details: http://developer.android.com/guide/topics/graphics/2d-graphics.html

提交回复
热议问题