material-components-android icon indicating copy to clipboard operation
material-components-android copied to clipboard

[Snackbar] Snackbar bottom margin is incorrect when using window insets with padding

Open aleksandra-krzemien opened this issue 2 years ago • 9 comments
trafficstars

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. Zrzut ekranu 2023-06-9 o 15 54 13

When insets update padding, snackbar gets extra bottom margin. It seems that navigation bar height is used twice. Zrzut ekranu 2023-06-9 o 15 54 27

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

aleksandra-krzemien avatar Jun 09 '23 14:06 aleksandra-krzemien