material-components-android
material-components-android copied to clipboard
[MaterialToolbar] Shadow is drawn over content with the same elevation
trafficstars
Description: The shadow from a MaterialToolbar will draw over content below it even if it is of the same elevation. For example, if I have a MaterialCardView with cardElevation=4dp that is directly below a MaterialToolbar with elevation=4dp, there will be a shadow cast on the MaterialCardView from the MaterialToolbar.
Expected behavior: I would expect that there is no shadow over the card, since it is the same elevation as the app bar.
Source code: Modify cat_topappbar_action_bar_activity.xml from the catalog app so that the contents is within a MaterialCardView:
<com.google.android.material.card.MaterialCardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:strokeWidth="0dp"
app:cardElevation="4dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/action_bar_demo_description"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"/>
<Button
android:id="@+id/action_bar_demo_action_mode_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/cat_topappbar_action_bar_toggle_action_mode_button"/>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
Then open the Action Bar Demo in the Catalog app.

Android API version: 31
Material Library version: 1.7.0-beta01
Device: Google Pixel 4a