CardView elevation not showing in lollipop and higher versions

Uma Achanta picture Uma Achanta · Jun 1, 2016 · Viewed 19.3k times · Source

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.

Answer

Uma Achanta picture Uma Achanta · Jun 2, 2016

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">`