2011-11-27 26 views
0

所以我有一个一般的图像旋转问题。我能够找到如何进行旋转并使其正确缩放,但现在我想将其设置为使图像在用户触摸的位置旋转。在选择点旋转图像

目前,一旦触摸,图像的顶部将旋转到最初发生触摸的位置。无论如何,它会保持在图像上的点,并从那一点开始旋转?

谢谢你的帮助。

+0

您应该发布一些您尝试过的代码,即使它不起作用。对于想要回答你的问题的人来说,这将是一大帮助! – aganders3

+0

如果您的问题已得到解答,请将解决方案作为答案发布,并通过单击答案旁边的检查来接受答案。 –

回答

0

修复了我的代码。只需在ACTION_DOWN被调用时获得初始度数,然后在ACTION_MOVE期间按照该度数偏移旋转。 下面的代码

 //Finds the initial degree where my finger is pressed. 
     case MotionEvent.ACTION_DOWN:{ 
      double arc = Math.atan2(event.getX() - v.getWidth()/2, v.getHeight()/2 - event.getY()); 
      initDegree = (float) Math.toDegrees(arc); 
      setTitle("counter" + counter++); 
      break;} 
     // Using the Initial Degree change I offset the degrees to send to my rotate function. 
     case MotionEvent.ACTION_MOVE:{ 
      double arc = Math.atan2(event.getX() - v.getWidth()/2, v.getHeight()/2 - event.getY()); 
      float degrees = (float) Math.toDegrees(arc); 
      rotate(degrees-initDegree); 
      break;}