This shrinks the clip bounds of the disappearing content from the full size to the size returned from [targetSize].
ExpandInShrinkOutSample
@Composable
fun ExpandInShrinkOutSample() {
var visible by remember { mutableStateOf(true) }
AnimatedVisibility(
visible,
enter =
expandIn(
// Overwrites the default spring animation with tween
animationSpec = tween(100, easing = LinearOutSlowInEasing),
// Overwrites the corner of the content that is first revealed
expandFrom = Alignment.BottomStart,
) {
// Overwrites the initial size to 50 pixels by 50 pixels
IntSize(50, 50)
},
exit =
shrinkOut(
tween(100, easing = FastOutSlowInEasing),
// Overwrites the area of the content that the shrink animation will end on. The
// following parameters will shrink the content's clip bounds from the full size of
// the
// content to 1/10 of the width and 1/5 of the height. The shrinking clip bounds
// will
// always be aligned to the CenterStart of the full-content bounds.
shrinkTowards = Alignment.CenterStart,
) { fullSize ->
// Overwrites the target size of the shrinking animation.
IntSize(fullSize.width / 10, fullSize.height / 5)
},
) {
// Content that needs to appear/disappear goes here:
Text("Content to appear/disappear", Modifier.fillMaxWidth().requiredHeight(200.dp))
}
}