I wanted to know how I add shadows to the cardview, I have used these two codes but it is added inside and the linear gradient is not what I am looking for, I am looking for the shadows to come out of the cardview and be black as if it were raised a little from the ground and cast a shadow I do not know if I explain myself very well
This is the cardview code in the snippet, I show only the important part
<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:gravity="center"
android:orientation="vertical"
>
<androidx.cardview.widget.CardView
android:layout_width="380dp"
android:layout_height="200dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="50dp"
android:layout_marginRight="8dp"
app:cardBackgroundColor="#3D3D3D"
app:cardCornerRadius="5dp"
android:background="@drawable/marco_cardview_videos"
app:cardElevation="50dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:background="@drawable/marco_cardview_videos">
In the 2 lineaLayout is where I have a drawable that I have put the white frame of the cardview
This is the drawable that I have to make the white frame that at the same time makes the gradient attempt
<shape xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
tools:ignore="ExtraText"
android:shape="rectangle">
<stroke
android:width="3sp"
android:color="@color/myWhite"/>
<padding
android:bottom="8sp"
android:left="8sp"
android:right="8sp"
android:top="8sp"/>
<corners android:radius="1dp"/>
<gradient
android:type="linear"
android:angle="45"
android:startColor="#D3D3D3"
android:endColor="#3D3D3D" />
Apparently android studio cardviews have the ´cardElevation´ class with which you can raise the cardview more or less and shadows are created automatically, the example I used.