Animate rotation of an image in Android

后端 未结 4 537
暗喜
暗喜 2021-01-14 08:08
  • I have a gear image which I want to continuously rotate about a fixed point.

  • Earlier I was accomplishing this by including the image in my Android

4条回答
  •  梦毁少年i
    2021-01-14 09:03

    I want to rotate a custom image as progress dialog in my application. You can use the code below to rotate an image:

    RotateAnimation anim = new RotateAnimation(0.0f, 360.0f , 
    Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f);
    anim.setInterpolator(new LinearInterpolator());
    anim.setRepeatCount(Animation.INFINITE);
    anim.setDuration(1000);
    imageView.setAnimation(anim);
    imageView.startAnimation(anim);
    

提交回复
热议问题