Skip to content

Commit

Permalink
[TopAppBar] Fixed compress effect clipping on API 21-24
Browse files Browse the repository at this point in the history
Partially resolves #3603

PiperOrigin-RevId: 576102714
  • Loading branch information
hunterstich authored and paulfthomas committed Oct 26, 2023
1 parent 8ca016f commit 2ac8c1c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/java/com/google/android/material/appbar/AppBarLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -2593,11 +2593,20 @@ public void onOffsetChanged(
// children inside the ABL.
child.getDrawingRect(ghostRect);
ghostRect.offset(0, (int) -offsetY);
// If the ghost rect is completely outside the bounds of the drawing rect, make this child
// invisible. Otherwise, on API <= 24 a ghost rect that is outside of the drawing rect will
// be ignored and the child would be drawn with no clipping.
if (offsetY >= ghostRect.height()) {
child.setVisibility(INVISIBLE);
} else {
child.setVisibility(VISIBLE);
}
ViewCompat.setClipBounds(child, ghostRect);
} else {
// Reset both the clip bounds and translationY of this view
ViewCompat.setClipBounds(child, null);
child.setTranslationY(0);
child.setVisibility(VISIBLE);
}
}
}
Expand Down

0 comments on commit 2ac8c1c

Please sign in to comment.