Why there is no space between CardViews on Lollipop? Why there is no space between CardViews on Lollipop? android android

Why there is no space between CardViews on Lollipop?


Set this on a CardView:

app:cardUseCompatPadding="true"

From documentation:

Add padding in API v21+ as well to have the same measurements with previous versions.


Use this two tags below inside of your cardview:

app:cardPreventCornerOverlap="false"app:cardUseCompatPadding="true"


first image is the expected behavior of card view. when the card has elevation the shadow falls on the bottom layers. In the pre-lollipop devices the elevation is made by adding padding. so the pre-lollipop devices will have a padding around the card view.

Before L, CardView adds padding to its content and draws shadows to that area. This padding amount is equal to maxCardElevation + (1 - cos45) * cornerRadius on the sides and maxCardElevation * 1.5 + (1 - cos45) * cornerRadius on top and bottom.