需求背景 : 当轮胎压力过大时,轮胎变红并且闪烁
// 开始闪烁时调用
private void startFlash(ImageView iv) {
iv.setVisibility(View.VISIBLE);
AlphaAnimation animation = new AlphaAnimation(1, 0);
animation.setDuration(1000);
animation.setRepeatCount(-1);
iv.setAnimation(animation);
animation.start();
}
// 停止闪烁时调用
private void stopFlash(ImageView iv) {
iv.setVisibility(View.INVISIBLE);
iv.clearAnimation();
}