Shadow color android studio

799 Views Asked by At

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

1

There are 1 best solutions below

1
IODevBlue On

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));