我试图在CardView
背景上为开关颜色设置动画,但我得到了这个:
无法解析方法“setCardBackgroundColor(android.graphics.drawable.TransitionDrawable)”
如果CardView
不支持TransitionDrawable
,那我们怎么能做到这样呢?
public void setCardBackground(CardView cardView) {
ColorDrawable[] color = {new ColorDrawable(Color.BLUE), new ColorDrawable(Color.RED)};
TransitionDrawable trans = new TransitionDrawable(color);
//cardView.setCardBackgroundColor(trans);
trans.startTransition(5000);
}