Using activities the elevation works normally, after I put it in fragments, it got "flat".
Using activities the elevation works normally, after I put it in fragments, it got "flat".
It seems like a margin / fill problem, trying to set the cardUseCompatPadding attribute to true. For example:
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="6dp"
card_view:cardUseCompatPadding="true"
card_view:cardElevation="4dp"
card_view:cardCornerRadius="3dp">
Android doc explanation:
CardView adds additional fill to draw shadows on the platforms before L
This can cause Cards to have different sizes between L and before L. If you need to align CardView with other views, you may need to dimension specific API version capabilities to explain the changes. Alternatively, you can set the cardUseCompatPadding flag to true and CardView will add the same fill values on L platforms and then.
Since the creation of the cardUseCompatPadding flag the truth adds unnecessary gaps in the UI, the default value is false.