我在 View 上使用NineOldAndroid的 AnimatorSet
当我想摆脱动画并让视图消失时 - 什么也没有发生
我如何让视图消失?
public void showAnimation(boolean show) {
if (show) {
if (mTarget.getVisibility() != View.VISIBLE) {
// play sound
mTarget.setVisibility(View.VISIBLE);
pauseAnimation = false;
// start animation
initTargetAnimation();
}
} else {
pauseAnimation = true; //All of this block gets executed in the debugger, but none of it actually take effect
if (mTarget.getAnimation() != null) {
mTarget.getAnimation().cancel();
mTarget.clearAnimation();
}
mTarget.setVisibility(View.GONE);
}
}
private void initTargetAnimation() {
final AnimatorSet set = new AnimatorSet();
// init animation properties
set.playTogether(ObjectAnimator.ofFloat(mTarget, "scaleX", RELEVANT_ANIMATION_SEQUENCE), ObjectAnimator.ofFloat(mTarget, "scaleY", RELEVANT_ANIMATION_SEQUENCE));
// add animation listener
set.setDuration(1500).addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
// RESTART ANIMATION
if (!pauseAnimation) {
initTargetAnimation(); // TODO fix
}
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
// start animation
set.start();
}