how to rotate an image continuously?

前端 未结 6 901
长情又很酷
长情又很酷 2021-01-04 08:26

I am trying to rotate this image by using a thread. what should I do?

     public class Start extends Activity {
        View base;
            Bitmap         


        
6条回答
  •  隐瞒了意图╮
    2021-01-04 08:49

    You can create an extension in Kotlin :

    fun ImageView.rotate(){
    val rotateAnimation = RotateAnimation(
        0f, 359f,
        Animation.RELATIVE_TO_SELF, 0.5f,
        Animation.RELATIVE_TO_SELF, 0.5f
    
    )
    rotateAnimation.duration = 300
    rotateAnimation.setAnimationListener(object : Animation.AnimationListener {
        override fun onAnimationStart(animation: Animation?) {}
        override fun onAnimationRepeat(animation: Animation?) {}
        override fun onAnimationEnd(animation: Animation?) {}
    })
    this.startAnimation(rotateAnimation)
    

    }

提交回复
热议问题