I have a CardView
inside another CardView
, but the child CardView
doesnt have shadow around it. Any idea why?
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
card_view:cardBackgroundColor="@color/WHITE_COLOR"
card_view:cardCornerRadius="20dp"
card_view:cardElevation="3dp"
card_view:cardPreventCornerOverlap="false"
card_view:contentPadding="0dp">
<android.support.v7.widget.CardView
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerInParent="true"
card_view:cardBackgroundColor="@color/RED_COLOR"
card_view:cardCornerRadius="20dp"
card_view:cardElevation="6dp"
card_view:cardPreventCornerOverlap="false"
card_view:contentPadding="0dp">
</android.support.v7.widget.CardView>
</android.support.v7.widget.CardView>
Use this code temporarily..
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
card_view:cardBackgroundColor="@color/WHITE_COLOR"
card_view:cardCornerRadius="20dp"
card_view:cardElevation="3dp"
card_view:cardPreventCornerOverlap="false"
card_view:contentPadding="0dp">
<android.support.v7.widget.CardView
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerInParent="true"
card_view:cardBackgroundColor="@color/RED_COLOR"
card_view:cardCornerRadius="20dp"
card_view:cardElevation="6dp"
card_view:cardPreventCornerOverlap="false"
card_view:contentPadding="0dp">
</android.support.v7.widget.CardView>
<View
android:layout_width="match_parent"
android:layout_height="4dp"
android:background="@drawable/shadow" />
</android.support.v7.widget.CardView>
Include this xml code in drawable folder under the name shadow.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="@android:color/transparent"
android:endColor="#40000000"
android:angle="90" />
</shape