Card View shadow much thicker at the bottom than at the top

Nir Arbel picture Nir Arbel · Jan 22, 2017 · Viewed 8.7k times · Source

I have an app that uses CardViews very extensively, pretty much for every UI element in each view. I noticed that the shadow around each CardView is much thicker around views close to the bottom than it is around views closer to the top:

example

Any idea why that is, and if there's a way to change that behavior?

Answer

harshithdwivedi picture harshithdwivedi · Jan 22, 2017

That is so because that is what Material Design was mean to represent.

CardView appears to be thick at the bottom as that represents the shadow which a real card will cast if the cardView was replaced by it.

If you want to tweak this parameter, you'll need to adjust the android:elevation="2dp" attribute for the cardView.

Setting it to 0dp will disable the shadow and increasing it will increase it.

If you want to have shadows all around the cardView, refer to this answer which explains how to achieve it.