Search code examples
androidandroid-5.0-lollipopandroid-6.0-marshmallowandroid-cardviewelevation

CardView elevation not showing in lollipop and higher versions


I was using cardview, but the problem is elevation not showing in lollipop and higher versions. please suggest me.Here is my code.

<android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/verify_card"
        android:layout_weight="1"
        card_view:cardBackgroundColor="@android:color/white"
        card_view:cardElevation="2sp"
        card_view:cardUseCompatPadding="true"
        />

Thanks in advance.


Solution

  • this worked for me.

    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    

    total code is:

    <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_margin="8dp"
        android:id="@+id/card_griditem"
        android:layout_height="match_parent"
        card_view:cardUseCompatPadding="true"
        card_view:cardElevation="4dp"
        card_view:cardCornerRadius="3dp">`