How Do I Use 'RotateDrawable'?

后端 未结 7 2141
没有蜡笔的小新
没有蜡笔的小新 2020-12-15 19:34

Could anyone tell me how they have got \'RotateDrawable\' to work whether it be from code or XML or both? The documentation on animating Drawables is pretty poor and animati

7条回答
  •  一整个雨季
    2020-12-15 20:22

    I would like to add a full example of animating a progress icon on ImageView, it is based on Mark Hetherington answer.

    So my animation looks as follows:

    
    
    

    icon comes from https://material.io/icons/

    then my layout contains an ImageView as follows:

            
    

    and finally in code when I need to show animation I do:

        RotateDrawable rotateDrawable = ((RotateDrawable)progressImage.getBackground());
        ObjectAnimator anim = ObjectAnimator.ofInt(rotateDrawable, "level", 0, 10000);
        anim.setDuration(1000);
        anim.setRepeatCount(ValueAnimator.INFINITE);
        anim.start();
    

提交回复
热议问题