I have a circle that I want to bounce, so it would expand in width, and collapse in height, then the reverse and the same for a few times. That all works with a few ScaleAnimations in a row. The problem is, that I want pivotY to be the bottom of the view. In this case every time a new animation starts it'll reset the pivot point to the center. Here's my code:
bounceAnimationPartOne = new ScaleAnimation(1.0f, 1.0f, 1.62f, 0.62f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 1.0f);
bounceAnimationPartOne.setDuration(45);
bounceAnimationPartOne.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
view.startAnimation(bounceAnimationPartTwo);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
bounceAnimationPartTwo = new ScaleAnimation(1.62f, 0.62f, 0.76f, 1.3f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 1.0f);
bounceAnimationPartTwo.setDuration(90);
bounceAnimationPartTwo.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
view.startAnimation(bounceAnimationPartThree);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
bounceAnimationPartThree = new ScaleAnimation(0.76f, 1.3f, 1.23f, 0.81f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 1.0f);
bounceAnimationPartThree.setDuration(105);
bounceAnimationPartThree.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
view.startAnimation(bounceAnimationPartFour);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
bounceAnimationPartFour = new ScaleAnimation(1.23f, 0.81f, 1.0f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 1.0f);
bounceAnimationPartFour.setDuration(60);