I am working with cardviews but the problem is my CardView is not showing any elevation or shadow. I have already tried some of the methods suggested in stackoverflow answer
Add this line in CardView widget
app:cardElevation="5dp"
hope this will help!
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="10dp"
app:cardCornerRadius="4dp"
app:cardBackgroundColor="#ffff8800">
......
</android.support.v7.widget.CardView>
Remove the background color first, add the elevation and later add the background again. Worked for me, though I had added the background through the layout designer.
If your manifest file has a android:hardwareAccelerated="false"
line, delete it.
Try adding android:outlineProvider="bounds"
to the CardView layout.
You forget two things.
AndroidManifest.xml
file, in the Application
tag you have to write<application android:hardwareAccelerated="true" ...>
instead of
<application android:hardwareAccelerated="false" ...>
Then check the parent tag of your layout file is there written like below line.
if you wanna use app:
xmlns. then write :
xmlns:app="http://schemas.android.com/apk/res-auto"
OR
xmlns:card_view="http://schemas.android.com/apk/res-auto"
NOTE: You don't need to write both simultaneous. Because it gives you duplicate attribute error.
The above line is most important when you use the attributes of res-auto
.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="@android:color/white"
app:cardCornerRadius="4dp"
app:cardElevation="4dp" />
</RelativeLayout>
remove below line from AndroidManifest.xml
android:hardwareAccelerated="false"