Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CardView elevation not showing in lollipop and higher versions

Tags:

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.

like image 500
Uma Achanta Avatar asked Jun 01 '16 14:06

Uma Achanta


People also ask

What is CardView elevation?

CardView uses elevation property on Lollipop for shadows and falls back to a custom emulated shadow implementation on older platforms. Due to expensive nature of rounded corner clipping, on platforms before Lollipop, CardView does not clip its children that intersect with rounded corners.

How do I customize my CardView?

Customized CardView First, add a CardView dependency to the application-level build. gradle file. Then create a drawable background for the cards. For that, create a new drawable resource file inside the drawable folder.

What is Android Card elevation?

CardView is a new widget in Android that can be used to display any sort of data by providing a rounded corner layout along with a specific elevation. CardView is the view that can display views on top of each other. The main usage of CardView is that it helps to give a rich feel and look to the UI design.


2 Answers

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">` 
like image 83
Uma Achanta Avatar answered Sep 21 '22 12:09

Uma Achanta


Make sure you have set android:hardwareAccelerated="false" as true in Manifest. By setting it to false your application will not able to use GPU and can't make some 2D designs.

like image 22
Bharat Lalwani Avatar answered Sep 22 '22 12:09

Bharat Lalwani