I tried to animate a switch-color on CardView
background, but I'm getting this:
Cannot resolve method 'setCardBackgroundColor(android.graphics.drawable.TransitionDrawable)'
If CardView
does not support TransitionDrawable
, then how can we achieve something like this?
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);
}