Stylianos Gakis
08/26/2021, 9:56 PMAnimatedVisibility
inside a box, so no row or column scope. It works alright but the clipping of how the animation opens up is a square. Meaning that it looks awkward as it comes into the screen especially since the shadows are looking weird. Is there a way to provide a clipping of how it should be expanded just like how I am passing that it should be expanding from the center?Stylianos Gakis
08/26/2021, 9:57 PMBox(Modifier.weight(1f)) {
androidx.compose.animation.AnimatedVisibility(
visible = isVisible,
modifier = Modifier
.padding(end = 8.dp, bottom = 8.dp)
.requiredSize(56.dp),
enter = fadeIn() + expandIn(
expandFrom = Alignment.Center,
),
exit = fadeOut() + shrinkOut(
shrinkTowards = Alignment.Center
),
) {
FloatingActionButton(
onClick = { }
) {
Text("Up!")
}
}
}
Doris Liu
08/26/2021, 11:42 PMStylianos Gakis
08/27/2021, 12:06 AMDoris Liu
08/27/2021, 12:09 AMDoris Liu
08/27/2021, 12:56 AMAnimatedVisibility(
visible = isVisible,
modifier = Modifier
.padding(end = 8.dp, bottom = 8.dp).requiredSize(56.dp)
.wrapContentSize().clip(CircleShape), // <------Add these two
enter = fadeIn() + expandIn(
expandFrom = Alignment.Center,
),
exit = fadeOut() + shrinkOut(
shrinkTowards = Alignment.Center
),
) {
FloatingActionButton(
onClick = { },
) {
Text("Up!")
}
}
Doris Liu
08/27/2021, 12:57 AMStylianos Gakis
08/27/2021, 1:46 AMJohan Reitan
08/27/2021, 6:50 AMDoris Liu
08/27/2021, 5:22 PMfadeIn/Out(..) + scaleIn/Out(animationSpec = tween(...))
BTW, nested AnimatedVisibility with exact same visible boolean could be simplified as one outer AnimatedVisibility and Modifier.animateEnterExit
for the inner one. The outer AnimatedVisibilityScope
is accessible to non-direct children. It could be something like:
AnimatedVisibility(....) {
...
MaterialFloatingActionButton(
modifier = otherModifier.animateEnterExit(enter = scaleIn(...), exit = scaleOut(...)),
...) {
transition.animateFloat(...) {...} // <-----Accessing the outer AVScope's transition property
content()
}
}
Johan Reitan
08/27/2021, 8:45 PM