Я решил использовать другую реализацию для более старых и новых Android
Для Android 21+ (layout-v21 / activity_main.xml):
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">
<include layout="@layout/toolbar_view"/>
</com.google.android.material.appbar.AppBarLayout>
<include layout="@layout/content"/>
</LinearLayout>
Для старых версий Android (layout / activity_main.xml):
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/toolbar_view"/>
<FrameLayout android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/content"/>
<View android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@drawable/drop_shadow"/>
</FrameLayout>
</LinearLayout>
toolbar_view.xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppTheme.ActionBar"
xmlns:android="http://schemas.android.com/apk/res/android"/>
drawable / drop_shadow.xml (чтобы добавить высоту под панелью инструментов для старого Android):
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="@android:color/transparent"
android:endColor="#88666666"
android:angle="90"/>
</shape>