Android的ObjectAnimation只启动了一次 [英] Android ObjectAnimation only started once

查看:129
本文介绍了Android的ObjectAnimation只启动了一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用的是ObjectAnimator API(android.animation.ObjectAnimator)一旦它的点击动画按钮(v是按钮):

I use the ObjectAnimator API (android.animation.ObjectAnimator) to animate a button once it's clicked (v is the Button):

ObjectAnimator animator = ObjectAnimator.ofFloat(v, "rotationY", 360f);
animator.setDuration(5000);
animator.start();

当我测试这个在模拟器上,它适用于第一次点击(按钮旋转)。但是,当我再次点击该按钮(该片段是不是第一次点击后销毁等),我没有看到任何动画在模拟器(模拟器不是最快的,但是,拥有5秒我应该看到的东西)。

When I test this on the emulator, it works for the first click (button rotates). But when I click the button again (the fragment is not destroyed etc. after the first click), I don't see any animation on the emulator (the emulator isn't the fastest, but with 5 seconds I should see something).

我需要摧毁的第一个动画或者我丢失后/关闭的东西吗?
任何人都不会有提示或可重现此?

Do I need to destroy/close something after the first animation or what am I missing? Does anyone have a hint or can reproduce this?

在此先感谢,
马丁

Thanks in advance, Martin

推荐答案

第二次你会尝试从360.0f动画到360.0f。更改)您的来电ofFloat(为:

The second time you will try to animate from 360.0f to 360.0f. Change your call to ofFloat() to:

ObjectAnimator.ofFloat(v, "rotationY", 0.0f, 360.0f)

这篇关于Android的ObjectAnimation只启动了一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆