Android:ValueAnimator总是给出最终值
下面我要配置ValueAnimator,以便在两种颜色之间进行交叉淡入。但它不起作用。它总是给出结束颜色值Android:ValueAnimator总是给出最终值,android,animation,Android,Animation,下面我要配置ValueAnimator,以便在两种颜色之间进行交叉淡入。但它不起作用。它总是给出结束颜色值 Integer colorFrom; Integer colorTo; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mGoogleApiClient = buildGoogleApiClient(); activity = getActi
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
无法找出问题所在?确保您的设备中已启用动画
“开发人员选项”
,如果禁用,您的动画只需从“开始”
跳到“结束”
值确保您的设备中已启用动画“开发人员选项”非常感谢。它解决了问题。@pskink请把你的评论作为回答,我会接受的。我正在清理我的qas:)天哪,那浪费了我这么多时间!由于性能原因,我在手机上禁用了所有动画,无法想象它会影响ValueAnimator
和其他相关类!谢谢你救了我剩下的时间:)天哪,救命恩人!想想我花了几个小时试图弄明白为什么我的进度条不再显示了。。。