如何在Android中几秒钟后重启对象动画师?

时间:2017-01-25 12:02:24

标签: android objectanimator

我的代码看起来像这样:

objectAnimator animator = ObjectAnimator.ofFloat(view, "rotation", 0f, (float) truePosition);
        animator.setDuration(totalTime);
        animator.setInterpolator(new DecelerateInterpolator());
        animator.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animator) {
                einsatz = 0;
                disableChips();
                imageRoulette.setEnabled(false);
            }

            @Override
            public void onAnimationEnd(Animator animator) {
                imageRoulette.setEnabled(true);
                imageRoulette.setImageDrawable(null);
                imageRoulette.setBackgroundResource(R.drawable.roulette);

                enableChips();
                printNumberAfterRotation(randPosition);
                myBets.clear();
                einsatz = -1;
                gesamtEinsatz = 0;
            }

            @Override
            public void onAnimationCancel(Animator animator) { }

            @Override
            public void onAnimationRepeat(Animator animator) { }
});
animator.start();

到现在为止,我总是需要点按视图来旋转图像。有没有办法在10秒后重新启动它? 你对如何解决它有什么建议吗?

1 个答案:

答案 0 :(得分:0)

 @Override
            public void onAnimationEnd(Animator animator) {
                animation.setStartDelay(10000); // 10 SEC
                animation.start();
            }