Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CardView inside CardView Doesn't Have Shadow

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>
like image 980
JayVDiyk Avatar asked Mar 09 '26 09:03

JayVDiyk


1 Answers

I have met exactly the same problem

card_view:cardUseCompatPadding="true" 

solved it

so every card looks like

                <android.support.v7.widget.CardView
                    card_view:cardUseCompatPadding="true"
                    card_view:cardElevation="4dp"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">
                   ...
                </android.support.v7.widget.CardView>
like image 51
Andrey Danilov Avatar answered Mar 11 '26 04:03

Andrey Danilov