Skip to content

Commit 904d063

Browse files
committed
Update Snackbar gesture inset calculation to factor in translationY
Fixes issue of compounding margins for legacy Snackbar which uses a slide animation that affects it's position on the screen Resolves #741 PiperOrigin-RevId: 285246645 (cherry picked from commit 86b2ec3)
1 parent a718fd1 commit 904d063

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/java/com/google/android/material/snackbar/BaseTransientBottomBar.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,10 @@ public boolean handleMessage(@NonNull Message message) {
263263
new Runnable() {
264264
@Override
265265
public void run() {
266-
int currentInsetBottom = getScreenHeight() - getViewAbsoluteBottom();
266+
// Calculate current bottom inset, factoring in translationY to account for where the
267+
// view will likely be animating to.
268+
int currentInsetBottom =
269+
getScreenHeight() - getViewAbsoluteBottom() + (int) view.getTranslationY();
267270
if (currentInsetBottom >= extraBottomMarginGestureInset) {
268271
// No need to add extra offset if view is already outside of bottom gesture area
269272
return;

0 commit comments

Comments
 (0)