Nir Arbel
Nir Arbel

Reputation: 325

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

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?

Upvotes: 4

Views: 12428

Answers (2)

Sergey Voloshyn
Sergey Voloshyn

Reputation: 74

It's a normal behavior of android:elevation

If you want to have the same thick for top and bottom, use own background.

For example, you can use nine patch image. Shadow generator: http://inloop.github.io/shadow4android/

Upvotes: 0

harshithdwivedi
harshithdwivedi

Reputation: 1421

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.

Upvotes: 2

Related Questions