0

我看到很多问题,但没有找到任何类似的模式。我研究了很多。 我有一个图像旋转在36°。 我用过setFillAfter()和setFillEnabled()。这是保存位置,但如果我再次旋转它从原来的位置开始。我希望它从旋转后的位置开始。点击一次后图像开始从起始位置旋转

Animation animation = new Animation (0,36, Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f); 
animation.setDuration(3000); 
animation.setInterpolator(new LinearInterpolator()); 
animation.setFillAfter(true); 

myImage.startAnimation(animation); 

回答

0

你只需要传递的ImageView的电流角度动画构造函数,而不是每次0。尝试下面的代码:

 int rotationAngle=36;/*angle by which you want to rotate image*/ 
     int mCurrRotation = 0; /*current angle of image*/ 

     buttonRotate.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      float fromRotation = mCurrRotation; 
      float toRotation = mCurrRotation += rotationAngle; 

      Animation animation = new RotateAnimation(
        fromRotation, 
        toRotation, 
        Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); 


      animation.setDuration(3000); 
      animation.setFillAfter(true); 
      myImage.startAnimation(animation); 
     } 
    }); 
0

对于执行旋转集后X光图像,以新的位置,它得到了旋转的y坐标...

相关问题