Reputation: 2214
I've tried all the stuff. my manifest is
<application
android:hardwareAccelerated="true"
my layout is :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="240dp"
android:layout_height="200dp">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:layout_above="@+id/tvName"
сard_view:elevation="4dp"
xmlns:сard_view="http://schemas.android.com/apk/res-auto"
сard_view:cardUseCompatPadding="true"
сard_view:cardCornerRadius="5dp">
<ImageView
android:id="@+id/ivPoster"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:adjustViewBounds="true"/>
</androidx.cardview.widget.CardView>
<TextView
android:id="@+id/tvName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="bottom|center_horizontal"
android:layout_alignParentBottom="true"
android:minLines="1"
android:singleLine="true"
android:ellipsize="marquee"
android:textSize="16sp"
android:layout_marginBottom="16dp"/>
</RelativeLayout>
So, inside RecyclerView with grid layout doesn't show any shadow, although it shows it in Android Studio shows shadow in preview
Upvotes: 0
Views: 134
Reputation: 443
I think it's because ImageView overlaps shadows of the cardview, when you set images on your ImageView in the adapter. Give the image view some margin and shadow will show (but it will be ugly xD).
For testing I display 2 of the Cardviewbut but gave first one src. here is the result:
as you can see first one has no shadows.
Upvotes: 1