How Do I Use 'RotateDrawable'?

后端 未结 7 2140
没有蜡笔的小新
没有蜡笔的小新 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:26

    I haven't worked with a RotateDrawable, but if you're simply trying to animate rotation on a graphic, you don't need it. Drawables with a 'level' like RotateDrawable are meant to convey information rather than animate views.

    The following code rotates an ImageView around its center:

    ImageView myImageView = (ImageView)findViewById(R.id.my_imageview);
    
    AnimationSet animSet = new AnimationSet(true);
    animSet.setInterpolator(new DecelerateInterpolator());
    animSet.setFillAfter(true);
    animSet.setFillEnabled(true);
    
    final RotateAnimation animRotate = new RotateAnimation(0.0f, -90.0f,
        RotateAnimation.RELATIVE_TO_SELF, 0.5f, 
        RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    
    animRotate.setDuration(1500);
    animRotate.setFillAfter(true);
    animSet.addAnimation(animRotate);
    
    myImageView.startAnimation(animSet);
    
    0 讨论(0)
提交回复
热议问题