material-components-android
material-components-android copied to clipboard
[Snackbar] Snackbar bottom margin is incorrect when using window insets with padding
Description:
Snackbar with anchor has incorrect bottom margin when window insets are used that set container padding instead of margin.
When insets update margin, snackbar is shown correctly above the anchor button.
When insets update padding, snackbar gets extra bottom margin. It seems that navigation bar height is used twice.
Expected behavior: Snackbar should always be displayed right above the anchor.
Source code:
The issue is most probably somewhere in BaseTransientBottomBar, but I wasn't able to identify exact place.
Minimal sample app repro:
https://github.com/aleksandra-krzemien/nested-nav-graphs-example/tree/krzemien/snackbar-inset-handling
Tap on to first fragment button to open FirstFragment. Current code will use insets with margin, so you will see situation on the first screenshot above (correct).
If you comment FirstFragment lines 41-43 and uncomment line 45, insets will update padding, and you'll end up with situation from second screenshot (incorrect).
Android API version: 29
Material Library version: 1.9.0
Device: Pixel 4a