//從藍色到紅色的背景變化
private void toggleBackgroundColor(int BLUE, int ORANGE,int RED, long duration) {
ValueAnimator colorAnim = ObjectAnimator.ofInt(findViewById(R.id.root), "backgroundColor", BLUE,ORANGE, RED);
colorAnim.setDuration(duration);
colorAnim.setEvaluator(new ArgbEvaluator());
colorAnim.setRepeatCount(0);
colorAnim.setRepeatMode(ValueAnimator.RESTART);
colorAnim.start();
mColorAnim = colorAnim.clone();
}
//從0到最大值的變化
private void changeText(int size) {
ValueAnimator valueAnimator = ValueAnimator.ofInt(0, size);
valueAnimator.setDuration(ANIMATION_DURATION_MILLIS);
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int progress = (int) animation.getAnimatedValue();
mTvPhoneScore.setText(progress + "MB");
}
});
valueAnimator.start();
}