使用android ObjectAnimator旋转和缩放可绘制对象
我看到了一些使用ObjectAnimator旋转和缩放使用android ObjectAnimator旋转和缩放可绘制对象,android,scale,android-4.4-kitkat,objectanimator,animatorset,Android,Scale,Android 4.4 Kitkat,Objectanimator,Animatorset,我看到了一些使用ObjectAnimator旋转和缩放ImageView的例子 但是,对于低于21的API,我想旋转和缩放一个Drawable(因此我不能使用AnimatedVectorDrawable) 它不像ImageView那样具有setRotation和setScaleX 我有什么简单的方法来实现这一点吗 rotationObjectAnimator = ObjectAnimator.ofFloat(rotationDrawable, "rotation", 0f, 360f); rot
ImageView
的例子
但是,对于低于21的API,我想旋转和缩放一个Drawable
(因此我不能使用AnimatedVectorDrawable
)
它不像ImageView
那样具有setRotation
和setScaleX
我有什么简单的方法来实现这一点吗
rotationObjectAnimator = ObjectAnimator.ofFloat(rotationDrawable, "rotation", 0f, 360f);
rotationObjectAnimator.setDuration(1000); // miliseconds
rotationObjectAnimator.start();
scaleObjectAnimator =
ObjectAnimator.ofPropertyValuesHolder(
scaleDrawable,
PropertyValuesHolder.ofFloat("scaleX", 0.5f),
PropertyValuesHolder.ofFloat("scaleY", 0.5f));
final AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playSequentially(rotationObjectAnimator, scaleObjectAnimator);