我有以下metod来配置我的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
无法弄清楚出了什么问题?
答案 0 :(得分:3)
确保您的设备"developer options"
启用了动画功能,如果已停用,您的动画只会从"start"
跳到"end"
值