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

あなただけアニメーションコンストラクタの代わりに、0たびにImageViewの現在の角度を渡す必要があります。コードの下に試してください。そのため

 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

を回転設定を行った後、Yは、それが回転してしまった新しい位置への画像のX座標...

関連する問題