Arpan24x7
Arpan24x7

Reputation: 668

shadow effect in android color cardview

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

Upvotes: 0

Views: 2615

Answers (1)

SlothCoding
SlothCoding

Reputation: 1706

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

Upvotes: 0

Related Questions