Java 尝试多次反转我的android动画
我有这个动画代码Java 尝试多次反转我的android动画,java,android,animation,android-animation,Java,Android,Animation,Android Animation,我有这个动画代码 private void shakeTooltip() { if (MapView.gpuSupported() != MapView.GPU_SUPPORTED) return; final TranslateAnimation breathUpTranslateAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0F, Animation.RELATIVE_
private void shakeTooltip() {
if (MapView.gpuSupported() != MapView.GPU_SUPPORTED) return;
final TranslateAnimation breathUpTranslateAnimation =
new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0F, Animation.RELATIVE_TO_SELF,
0.0F, Animation.RELATIVE_TO_PARENT, 0.0F, Animation.RELATIVE_TO_SELF, -0.05F);
breathUpTranslateAnimation.setDuration(TOOLTIP_ANIM_DURATION * 3);
breathUpTranslateAnimation.setRepeatCount(2);
breathUpTranslateAnimation.setRepeatMode(Animation.REVERSE);
breathUpTranslateAnimation.setInterpolator(new DecelerateInterpolator());
// breathUpTranslateAnimation.setFillAfter(true);
toolTipLayout.startAnimation(breathUpTranslateAnimation);
}
我希望我的视图上下移动2次,并在向下位置结束动画
但是,现在它向上、向下、向上移动,然后向下移动,而不使用平移动画
好像它真的重新启动了。它出现在向下位置,不在那里移动
如何解决此问题?您应该将重复计数设置为3。您看到的跳回是因为动画的setFillAfter默认为false,如果手动将其设置为true,它将在动画结束时保持不变。因此,您需要将重复计数增加到3 但是为什么呢?一路飙升。第二名-下降。第3次-再次上升?重复计数不计算动画第一次出现的次数,它计算动画第一次出现后重复的次数。因此,当您将“重复计数”设置为3时:0-向上(不是重复)、1-向下(重复)、2-向上(重复)、3-向下(重复)。