Android Animate Rotate

前端 未结 5 475
醉酒成梦
醉酒成梦 2020-12-08 00:12

I did some digging in Android code, and saw the use of in the indeterminate progress bar. after trying to create my own drawable with this tag:



        
5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-08 00:53

    I ran into the exact same issue. You can exclude those parameters (framesCount and frameDuration), and it may work for you. I tried just excluding them and it animated fine, but the width/height I was setting were not being respected, so I ended up creating a simple rotation animation and an ImageView to apply it to. Here's the animation file (res/anim/clockwise_rotation.xml):

    
    
    

    Then you just inflate your Animation, set repeat count, and start it from the View

    Animation rotation = AnimationUtils.loadAnimation(this, R.anim.clockwise_rotation);
    rotation.setRepeatCount(Animation.INFINITE);
    myView.startAnimation(rotation);
    

提交回复
热议问题