我该怎么做,当一个动画完成的东西吗?怎么做、我该、东西、动画

由网友(享受不起牛奶那种味道)分享简介:我有一个的ImageView ,我用它来显示通过一个进度 AnimationDrawable 。当我想告诉我的进步微调,我这样做:I have an ImageView that I use to show progress via an AnimationDrawable. When I want to show...

我有一个的ImageView ,我用它来显示通过一个进度 AnimationDrawable 。当我想告诉我的进步微调,我这样做:

I have an ImageView that I use to show progress via an AnimationDrawable. When I want to show my progress spinner, I do this:

animDrawable.start();
ObjectAnimator.ofFloat(view, "alpha", 1.0f).setDuration(300).start();

当我想隐藏的微调,我这样做:

When I want to hide the spinner, I do this:

ObjectAnimator.ofFloat(view, "alpha", 0.0f).setDuration(300).start();
animDrawable.stop();

然而,这具有这样的动画立即停止的效果。我想它停止后,才 ObjectAnimator 已完全褪去0.0阿尔法。有没有一种方法,我可以设置沿着一个AnimationCompleted回调线的东西?

However, this has the effect that the animation stops immediately. I would like it to stop only after the ObjectAnimator has completely faded to 0.0 alpha. Is there a way I can setup something along the lines of an "AnimationCompleted" callback?

推荐答案

看起来像base类有一个监听。

ObjectAnimator anim = ObjectAnimator.ofFloat(view, "alpha", 0.0f);
anim.addListener(new AnimatorListener() {
    ...
    @Override 
    public void onAnimationEnd(Animator animation) {
        animDrawable.stop()            
    }
    ...
});
anim.setDuration(300).start();
阅读全文

相关推荐

最新文章