material-components / material-components/material-components-android

[MaterialToolbar] Shadow is drawn over content with the same elevation

Open
#2,918 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Widget: TopAppBar
Dominant language
Java
Stars
17.4k
Forks
3.2k
PR merge metrics
No merged PRs in 30d

Description

**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`:
```xml



```

Then open the Action Bar Demo in the Catalog app.

![Screenshot_20220817-162432_M3 Catalog](https://user-images.githubusercontent.com/4050143/185260653-18d6f57c-bd8b-4394-a10b-74715545ecd4.png)

**Android API version:** 31

**Material Library version:** 1.7.0-beta01

**Device:** Google Pixel 4a

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue by updating cat_topappbar_action_bar_activity.xml in the catalog app with the provided MaterialCardView, then open the Action Bar Demo. Trace how MaterialToolbar elevation and its shadow are rendered relative to the card. Done means content at the same 4dp elevation no longer receives a visible toolbar shadow.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.