0

如果我根据某些持续时间和度数参数创建 RotateAnimation,但我想用不同的持续时间和度数参数调用相同的动画,我该怎么做?

RotateAnimation animation = new RotateAnimation(fromDegrees, toDegrees, width, height/2);
        animation.setInterpolator(new LinearInterpolator());
        animation.setDuration(animationDuration);
        animation.setFillAfter(true);
        animation.setAnimationListener(new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
                activityTimeOrRepeat.setText(task.getDurationTitle());
                activityTimeOrRepeat.setTextColor(textColor);
                activityDescription.setText(task.getTitle());
                activityDescription.setTextColor(textColor);
                timeLeftForThisActivity.setTextColor(textColor);
                currentTimerIndex[0] = index;
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                timeLeftForThisActivity.setText("00:00");
                CountDownTimer currentTimer = timers[index];
                currentTimer.cancel();

                if (index == taskSize - 1) {
                    overallTimer[0].cancel();
                    startButton.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.done_button_master));
                    startButton.setTag(context.getString(R.string.wtrDoneButtonTag));
                    elapsedTimeDynamic.setText(String.format("%02d:%02d", (totalActivityTime / 1000) / 60, (totalActivityTime / 1000) % 60));
                }
                else {
                    RotateAnimation nextAnimation = animations[index + 1];
                    CountDownTimer nextTimer = timers[index + 1];
                    nextTimer.start();
                    workoutWidget.startAnimation(nextAnimation);
                }
            }
        });

如何调用相同的动画,但具有不同的持续时间和度数参数?

4

0 回答 0