0

I'm trying to create a custom Shadow Drawable, like the picture below

Shadow

This is not a normal Material Shadow, first it has a bigger radius, and has a halo effect on all sides (top, bottom, right, left).

I've tried Gradient, but it only has a circular radius, which won't work here because this is rectangular.

I even tried making the CardView elevated to like 100 DP, but apparently the elevation has a limit.

I looked online for some solutions, and most were very complicated and limited, while others were about older implementations of shadow (back in Android 4.0)


Any idea how I can achieve a shadow like this? It's created by the designer in Adobe XD.

Ahmad Sattout
  • 1,755
  • 13
  • 33
  • In my case, it often helped building up a layer-list drawable file. I know, that is it not realtime but with layer-list you can create nice shadows by putting a shadow drawable in background. I am sure that you can create a layer-list drawable also in java, so it is possible to generate it automatically. For creating layer-list: https://stackoverflow.com/questions/38143181/programmatically-create-layer-list – ValiSpaceProgramming Jan 04 '21 at 12:10
  • And for creating drawable maybe as a little help: https://stackoverflow.com/questions/28578701/how-to-create-android-shape-background-programmatically – ValiSpaceProgramming Jan 04 '21 at 12:10
  • Possible duplicate see this: https://stackoverflow.com/questions/15333529/how-to-provide-shadow-to-button – KyluAce Jan 04 '21 at 13:08
  • None of these answers give even a close result to the desired shadow – Ahmad Sattout Jan 11 '21 at 10:11

1 Answers1

0

For complex images that should scale according to screen sizes, I would export it as PNG exactly as it looked like in your image and then I would create a resizable bitmap (9-Patch file)

F.Mysir
  • 1,637
  • 20
  • 29