Reputation: 1041
This is my card_view. I have mentioned card_view:cardElevation
.
But still shadow is not showing.
I have searched many links. Everywhere they have mentioned to use card_view:cardElevation
.
<android.support.v7.widget.CardView
android:id="@+id/card_view"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardBackgroundColor="@color/white"
card_view:cardCornerRadius="4dp"
card_view:cardElevation="5dp"
card_view:cardUseCompatPadding="true"
app:cardPreventCornerOverlap="false">
</android.support.v7.widget.CardView>
Can you tell what I am missing here?
Upvotes: 1
Views: 4363
Reputation: 1
Set the following attribute in your cardview
card_view:cardUseCompatPadding = "true"
card_view:cardElevation = "5dp"
Upvotes: 0
Reputation: 22945
Read https://developer.android.com/training/material/lists-cards.html
To create a card with a shadow, use the card_view:cardElevation attribute. CardView uses real elevation and dynamic shadows on Android 5.0 (API level 21) and above and falls back to a programmatic shadow implementation on earlier versions. For more information, see Maintaining Compatibility.
UPDATE
try adding margin to card if you want to see shadow
check https://developer.android.com/reference/android/support/v7/widget/CardView.html
Upvotes: 4