gpt4 book ai didi

Android:ValueAnimator 总是给出最终值

转载 作者:太空狗 更新时间:2023-10-29 16:34:26 28 4
gpt4 key购买 nike

我有以下方法来配置我的 ValueAnimator 以在两种颜色之间交叉淡入淡出。但它不起作用。它总是给出结束颜色值。

Integer colorFrom;
Integer colorTo;

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mGoogleApiClient = buildGoogleApiClient();
activity = getActivity();
context = activity.getApplicationContext();
colorFrom = ContextCompat.getColor(context, R.color.donut_finished_color);
colorTo = ContextCompat.getColor(context, R.color.Red);
}

@Override
public void onResume() {
super.onResume();
setColorAnimation();
}

private void setColorAnimation() {
long passedTime = Calendar.getInstance().getTime().getTime() - currentEarlyDate.getTime();
colorAnimator = ValueAnimator.ofObject(argbEvaluator, colorFrom, colorTo);
colorAnimator.setDuration(currentPrayerTimeLength);
colorAnimator.setInterpolator(null);
colorAnimator.addUpdateListener(this);
colorAnimator.start();
colorAnimator.setCurrentPlayTime(passedTime);
}

@Override
public void onAnimationUpdate(ValueAnimator animation) {
Integer colorValue = (Integer) colorAnimator.getAnimatedValue();
Log.e(Constants.LOG_TAG, "Duration : " + colorAnimator.getDuration());
Log.e(Constants.LOG_TAG, "Current : " + colorAnimator.getCurrentPlayTime());
Log.e(Constants.LOG_TAG, "Color : " + colorValue);
remainingTimeProgress.setFinishedStrokeColor(colorValue);
remainingTimeProgress.setUnfinishedStrokeColor(colorValue);
}

时间值在日志上看起来是正确的,但动画颜色值跳到结束

09-02 17:53:22.032    updateLocationNamesList
09-02 17:59:30.104 setColorAnimation - Length : 10620000
09-02 17:59:30.104 setColorAnimation - Passed : 4290093
09-02 17:53:22.099 onAnimationUpdate - Duration : 10620000
09-02 17:53:22.099 onAnimationUpdate - Current : 0
09-02 17:53:22.099 onAnimationUpdate - Color : -16058881
09-02 17:53:22.100 onAnimationUpdate - Duration : 10620000
09-02 17:53:22.100 onAnimationUpdate - Current : 0
09-02 17:53:22.100 onAnimationUpdate - Color : -10183775
09-02 17:53:22.102 onAnimationUpdate - Duration : 10620000
09-02 17:53:22.102 onAnimationUpdate - Current : 2
09-02 17:53:22.102 onAnimationUpdate - Color : -65536 //Quickly jumps to end

不知道哪里出了问题?

最佳答案

确保您在设备“开发者选项”中启用了动画,如果禁用您的动画只是从“开始”跳到“结束”

关于Android:ValueAnimator 总是给出最终值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32356689/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com