Search code examples
androidcardviewandroid-elevation

Unwanted card shadow on android 4.2.2


I implemented a LisView that has nested card views with a custom ImageView for the shadow. Here's the layout :

  <android.support.v7.widget.CardView
        android:id="@+id/food_card_view"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="2dp"
        card_view:cardBackgroundColor="@android:color/transparent"
        card_view:cardCornerRadius="0dp"
        card_view:cardElevation="0dp"
        card_view:cardPreventCornerOverlap="false">

(... views here ...)

</android.support.v7.widget.CardView>

The problem is that the CardView shows has an elevation value on some devices, even if card_view:cardElevation="0dp" is set to 0dp.

enter image description here


Solution

  • I found the solution by deleting the CardView from the layout and inflating directly the LinearLayout that holds the item list view.