My layout file:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
tools:context=".TurnOnLocation">
<LinearLayout
android:id="@+id/requires_location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/turn_on_location">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="4dp"
app:cardElevation="10dp"
app:cardPreventCornerOverlap="false">
<TextView
android:id="@+id/info_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingStart="60dp"
android:paddingEnd="60dp"
android:textSize="28sp"
android:text="test"
android:textColor="@color/colorPrimary"
android:textAlignment="center"
android:background="@color/colorPrimaryDark" />
</androidx.cardview.widget.CardView>
</LinearLayout>
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/turn_on_location"
android:textColor="@color/colorPrimary"
android:textSize="@dimen/medium_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/turn_on_location"
app:layout_constraintTop_toBottomOf="@id/requires_location"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
I've specified the app:cardElevation="10dp"
which I believe is meant to render the drop shadow. However no shadow is appearing.
Any idea why?
You've no mistake in your source code. The shadow should be rendered correctly. You might be checking the output in your layout preview. It has some issue on rendering. Please run the app in emulator or real device.