Hesam Alipour
Hesam Alipour

Reputation: 1

Shadow color android studio

I have a ui design. I should to make some xml file with custom shadow color.

I used to carbon library but it not work very well

I need to create shadow like this example image of shadow applied to UI

Upvotes: 0

Views: 1231

Answers (1)

IODevBlue
IODevBlue

Reputation: 101

This should work for Android version 28 or higher.

In your xml layout, include this in your CardView.

android:outlineAmbientShadowColor="<yourColor>"
android:outlineSpotShadowColor="<yourColor>"

You can do the same in code by doing this:

mCardView.setOutlineAmbientShadowColor(ContextCompat.getColor(getContext(), R.color.color_blue));
mCardView.setOutlineSpotShadowColor(ContextCompat.getColor(getContext(), R.color.colour_blue));

Upvotes: 1

Related Questions