我有一个想要反弹的圆圈,所以它会在宽度上扩大,在高度上塌陷,然后反过来,同样的几次。这一切都适用于连续的几个 ScaleAnimations。问题是,我希望 pivotY 成为视图的底部。在这种情况下,每次新动画开始时,它都会将枢轴点重置为中心。这是我的代码:
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);