Android CardView with a custom shadow color

Davideas picture Davideas · Jul 8, 2015 · Viewed 27.8k times · Source

Is it possible to change the color of the shadow around the CardView? Mainly used to mark selected the card as it were lighted on?

Should be valid on L and pre-L devices.

Answer

BladeCoder picture BladeCoder · Jul 8, 2015

CardView shadow colors are defined in the resources of the CardView library. You can override them by redefining the resource value in your own project but you can not change them dynamically by code.

Edit: overriding the resource value only affects pre-Lollipop devices. On Lollipop and above, CardView always uses the native shadow implementation whose color cannot be changed.