How to change RecyclerView Card’s color dynamically

I have a RecyclerView that displays cards of same size and similar content. Does anyone knows how I would go about changing the cards color depending on the object it holds? So object “A” would have a blue card and object “B” would have a red card. I’ve seen visual design in the web accomplishing this but I was wondering if anyone would have sample code or suggestion on how to accomplish this.

Below is the “material design” cards I have on my development app:

material design cards


Source: android

Leave a Reply