仿iOS后台通话时,通知栏的呼吸字体动画

iPone通话时,退到后台的话,通知栏会有提示“正在通话,通话时长05:12”,感觉挺不错了,仿了一个


import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.Gravity;
import android.widget.TextView;

public class BreathTextView extends TextView{

	
	ValueAnimator animator;
	public BreathTextView(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
		init();
	}
	public BreathTextView(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
		init();
	}

	public BreathTextView(Context context, AttributeSet attrs, int defStyleAttr) {
		super(context, attrs, defStyleAttr);
		// TODO Auto-generated constructor stub
		init();
	}

	private void init(){
		animator=ObjectAnimator.ofInt(this,"textColor",0xFFFFFFFF,0x00FFFFFF);
		animator.setDuration(1000);
		animator.setEvaluator(new ArgbEvaluator());
		animator.setRepeatCount(ValueAnimator.INFINITE);
		animator.setRepeatMode(ValueAnimator.REVERSE);
	}
	@Override
	protected void onAttachedToWindow() {
		// TODO Auto-generated method stub
		super.onAttachedToWindow();
		animator.start();
	}
	@Override
	protected void onDetachedFromWindow() {
		// TODO Auto-generated method stub
		super.onDetachedFromWindow();
		animator.cancel();
	}
}

你可能感兴趣的:(仿iOS后台通话时,通知栏的呼吸字体动画)