For some reason, elevation works in ConstraintLayout if you set a dummy object to draw as the background:
Create a drawing:
dummyBg.xml
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="rectangle"> <solid android:color="@android:color/white"/> <corners android:radius="2dp" /> </shape> </item> </layer-list>
Use this as the background for the view and use the elevation as usual.
android:elevation="8dp" android:background="@drawable/dummyBg" android:padding="4dp"
So you get:
<TextView android:id="@+id/list_ssid" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginEnd="8dp" android:layout_marginLeft="8dp" android:layout_marginRight="8dp" android:layout_marginStart="8dp" android:layout_marginTop="6dp" android:layout_marginBottom="2dp" android:elevation="8dp" android:background="@drawable/dummyBg" android:padding="4dp" android:text="SSID" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toLeftOf="@+id/guideline" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent"/>
source share