移動開發---背景漸變色(由藍色變成紅色),以及數字變化

//從藍色到紅色的背景變化
	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();
    }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章