使用 TransitionDrawable 为 CardView 背景颜色设置动画
public void setCardColorTran(CardView card) {
ColorDrawable[] color = {new ColorDrawable(Color.BLUE), new ColorDrawable(Color.RED)};
TransitionDrawable trans = new TransitionDrawable(color);
if(Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
card.setBackground(trans);
} else {
card.setBackgroundDrawable(trans);
}
trans.startTransition(5000);
}