013himanshu
013himanshu

Reputation: 53

CardView does not show elevation at run time

Here is the xml code :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.himanshu.staticlogin.MainActivity"
android:weightSum="1">
<android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    card_view:cardBackgroundColor="@color/cardview_dark_background"
    card_view:cardElevation="10dp"
    android:clickable="true"
    />
</LinearLayout>

It shows elevation in the preview but when I run the file it does not. What am I doing wrong?

Upvotes: 1

Views: 140

Answers (2)

Reza Nazeri
Reza Nazeri

Reputation: 315

set for cardview:

card_view:cardUseCompatPadding="true"

Upvotes: 2

coder
coder

Reputation: 3273

Use card_view:cardUseCompatPadding="true" in your xml to show elevation on pre Lollipop androids.

Upvotes: 0

Related Questions