对象动画只会为对象设置一次动画

Object Animation will only animate object once

按钮 (randomButton) 设置动画后,将不再设置动画 - 但是为什么?每次调用 ObjectAnimator 时如何强制执行动画?

Button randomButton = eliminate();
randomButton.setText("");
objectAnimator = ObjectAnimator.ofFloat(randomButton, "rotation", 180);
objectAnimator.setDuration(500);
objectAnimator.start();

您需要第二个值才能使对象恢复活力。

objectAnimator = ObjectAnimator.ofFloat(randomButton, "rotation", 180);

这是来自https://developer.android.com/reference/android/animation/ObjectAnimator、"A single value implies that that value is the one being animated to, in which case the start value will be derived from the property being animated and the target object when start() is called for the first time. Two values imply starting and ending values. More than two values imply a starting value, values to animate through along the way, and an ending value (these values will be distributed evenly across the duration of the animation)."

正确的代码是:

    objectAnimator = ObjectAnimator.ofFloat(randomButton, "rotation", 0, 180);