I want to start an animation of a button. The animation works fine, but I want the animation will repeat. How can I do this? I have look for an answer for days. My code:
floatingActionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Start the animation
v.animate().setDuration(200)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
}
})
// Rotate
.rotation(rotated ? 0f : 135f)
// Move up in first click, and down in second
.translationY(rotated ? 0f : -200f);
rotated = !rotated;
}
});
Can I repeat this animation "forever"?