大家好..
我正在使用来自Github的非常好的动画技术。这个家伙为我们提供了非常好的文字效果,我喜欢无限次地使用它们中的一些,不仅仅是当用户按下那个特定按钮然后播放那个效果时。
这是我的代码:
private YoYo.YoYoString rope;
rope = YoYo.with(Techniques.RollOut)
.duration(1200)
.interpolate(new AccelerateDecelerateInterpolator())
.withListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {}
@Override
public void onAnimationEnd(Animator animation) {}
@Override
public void onAnimationCancel(Animator animation) {}
@Override
public void onAnimationRepeat(Animator animation) {}
}).playOn(mTarget);
所以当我要在onAnimationEnd方法中添加此代码时,这是我的问题:
animation.setRepeatCount(Animation.INFINITE);
会出现错误并且说:“方法setRepeatCount(int)未定义类型Animator”。
如果您想继续,请转到我提供的Github地址。 所以,简而言之,我想无限次地重复动画。
答案 0 :(得分:1)
这个技巧对我有用。尝试
YoYo.with(Techniques.RollOut)
.duration(1200)
.interpolate(new AccelerateDecelerateInterpolator())
.withListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {}
@Override
public void onAnimationEnd(Animator animation) {
YoYo.with(Techniques.RollOut)
.duration(1200)
.interpolate(new AccelerateDecelerateInterpolator())
.withListener(this).playOn(mTarget);
}
@Override
public void onAnimationCancel(Animator animation) {}
@Override
public void onAnimationRepeat(Animator animation) {}
}).playOn(mTarget);
答案 1 :(得分:1)
我使用这样的重复方法。
YoYo.with(Techniques.Tada)
.duration(700)
.repeat(Animation.INFINITE)
.playOn(...);
答案 2 :(得分:0)
使用countDownTimer的最佳方式:
private void countDownForCustomAnimation(final int time){
new CountDownTimer(time, time){
@Override
public void onTick(long millisUntilFinished) {
}
@Override
public void onFinish() {
if(!isMainClickedYet){
YoYo.with(Techniques.RollOut)
.duration(timeforDuration)
.playOn(view);
countDownForCustomAnimation(time);
}
}
}.start();
}
答案 3 :(得分:0)
我使用下面的代码重复动画:
YoYo.with(Techniques.Wobble)
.repeat(YoYo.INFINITE)
.duration(5000)
.playOn(imgCycleRoad);