Skip to content

Commit 2ac8c1c

Browse files
hunterstichpaulfthomas
authored andcommittedOct 26, 2023
[TopAppBar] Fixed compress effect clipping on API 21-24
Partially resolves #3603 PiperOrigin-RevId: 576102714
1 parent 8ca016f commit 2ac8c1c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
 

‎lib/java/com/google/android/material/appbar/AppBarLayout.java

+9
Original file line numberDiff line numberDiff line change
@@ -2593,11 +2593,20 @@ public void onOffsetChanged(
25932593
// children inside the ABL.
25942594
child.getDrawingRect(ghostRect);
25952595
ghostRect.offset(0, (int) -offsetY);
2596+
// If the ghost rect is completely outside the bounds of the drawing rect, make this child
2597+
// invisible. Otherwise, on API <= 24 a ghost rect that is outside of the drawing rect will
2598+
// be ignored and the child would be drawn with no clipping.
2599+
if (offsetY >= ghostRect.height()) {
2600+
child.setVisibility(INVISIBLE);
2601+
} else {
2602+
child.setVisibility(VISIBLE);
2603+
}
25962604
ViewCompat.setClipBounds(child, ghostRect);
25972605
} else {
25982606
// Reset both the clip bounds and translationY of this view
25992607
ViewCompat.setClipBounds(child, null);
26002608
child.setTranslationY(0);
2609+
child.setVisibility(VISIBLE);
26012610
}
26022611
}
26032612
}

0 commit comments

Comments
 (0)
Please sign in to comment.