rob42
05/30/2024, 11:56 AMAnimatedVisibility
? A recent update to compose seems to have enabled clipping each item that appears by default, which has caused a UI regression in my app.
Docs suggest adding .using(SizeTransform(clip = false))
to the transitionSpec, but AnimatedVisibility doesn't take a transitionSpec, and my animations are actually applied by a series of Modifier.animateEnterExit(...)
on each item.Doris Liu
05/30/2024, 3:47 PMrob42
05/31/2024, 10:34 AMslideInVertically
with a large y offset. The desired effect is that the content slides up the screen into its final resting place. This is how it behaved before. Now, the content is clipped to its bounding box,.Doris Liu
05/31/2024, 4:58 PMBerkeli Alashov
10/17/2024, 11:54 PM@OptIn(ExperimentalLayoutApi::class)
@Composable
fun AnimatedText(
text: String,
modifier: Modifier = Modifier,
style: TextStyle = LocalTextStyle.current,
transitionSpec: AnimatedContentTransitionScope<Char>.() -> ContentTransform = {
(if (targetState > initialState) {
(slideInVertically { -it } + fadeIn()) togetherWith (slideOutVertically { it } + fadeOut())
} else {
(slideInVertically { it } + fadeIn()) togetherWith (slideOutVertically { -it } + fadeOut())
}).using(
SizeTransform(clip = false)
)
}
) {
FlowRow(
modifier = modifier
.animateContentSize()
// merge all text parts into one row so accessibility services can read it as one value
.clearAndSetSemantics { contentDescription = text },
horizontalArrangement = Arrangement.Start,
) {
text.forEachIndexed { charIndex, character ->
val transition = updateTransition(targetState = character, label = "CharacterTransition")
transition.AnimatedContent(
contentAlignment = Alignment.TopStart,
transitionSpec = transitionSpec,
) { characterState ->
Text(
text = characterState.toString(),
style = style
)
}
}
}
}
Doris Liu
10/18/2024, 11:31 PMModifier.animateContentSize
.Berkeli Alashov
10/21/2024, 10:12 PMDoris Liu
10/21/2024, 11:58 PMwhy exactly can't animateContentSize allow not clipping?
animatedContentSize
modifier is a clipBounds animation, if you remove the clipping you'll see no clipping, the content just jumps from small to large. In that case, you will only get an animated effect coming from the gradual size change, but visually it won't look great. Have you tried animating the content size from small to large?Berkeli Alashov
10/22/2024, 12:49 AM.graphicsLayer(translationX = with(density) { -12.toPx() })
applied to TextButton so it would appear left aligned with other elements (since textbutton has internal padding..)Berkeli Alashov
10/22/2024, 12:53 AMBerkeli Alashov
10/22/2024, 12:56 AMBerkeli Alashov
10/22/2024, 12:56 AM