0

enter image description here

Want this kind of shadow effect with android card view except for white background with cardview property, neither use with the canvas draw mechanism nor 9 patch image mechanism

want to use only drawable shape or cardview properties. TIA

Arpan24x7
  • 648
  • 5
  • 24

1 Answers1

0

EDIT: There is this github project you can use to get custom shadow for CardView. Just implement it in your project and use this instead of androidx components. Link: https://github.com/nvl2val/CardView/tree/master

2nd EDIT: Also another workaround for this issue. Read this thread: Android change Material elevation shadow color


I don't really get your question but CardView itself has a lot of properties you can play with. Check this documentation for more: https://developer.android.com/reference/androidx/cardview/widget/CardView

Using elevation will give you shadow by default so if you don't want a shadow on objects with a white background you need to set the elevation to 0. Here you can play with

  • android:elevation = "10dp"
  • app:cardElevation = "10dp"

and see which one does the job better for you. Also, try adding some padding to your parent layout so that CardView has some space around. All this and maybe more you can find in this answer: https://stackoverflow.com/a/46374054/14759470

SlothCoding
  • 1,546
  • 7
  • 14
  • tnx dude for your time this also used but it works with White BG only not for other color – Arpan24x7 Dec 30 '20 at 07:53
  • Are we talking about CardView White BG? You want your shadow on CardViews with Blue BG or what? I don't really understand your question, sorry. – SlothCoding Dec 30 '20 at 08:18
  • Yes, want a shadow on CardViews with Blue BG with a blue shadow or any custom color the same as a white color with gray color shadow. – Arpan24x7 Dec 30 '20 at 08:32
  • Well, you don't have that as an option but you can do a workaround. Instead of using androidx component CardView, make your own. Visit this link and check this out it does what you want, just implement it in your project and use it. I'll edit my first comment to add this if someone else is searching for the same thing. If you like it, mark it as response to this. https://github.com/nvl2val/CardView/tree/master – SlothCoding Dec 30 '20 at 11:01