Radoslaw Juszczyk
01/18/2024, 9:36 AMAnimatedContent
?
whatever I use it appears like it scales in / scales outFabricio Vergara
01/18/2024, 10:13 AMAnimatedContent(
targetState = expanded,
transitionSpec = {
slideInVertically(
initialOffsetY = { -it }
) togetherWith slideOutVertically(
targetOffsetY = { -it }
)
}
) { target ->
Box(modifier = Modifier.fillMaxWidth()) {
if (target) {
Text("Lorem ipsum")
}
}
}
idk the specifics of your needs, but it might workRadoslaw Juszczyk
01/18/2024, 10:38 AMRadoslaw Juszczyk
01/18/2024, 10:39 AMFabricio Vergara
01/18/2024, 10:39 AMRadoslaw Juszczyk
01/18/2024, 10:41 AMAnimatedContent(
isExpanded,
transitionSpec = {
ContentTransform(
EnterTransition.None,
ExitTransition.None,
sizeTransform = SizeTransform(
sizeAnimationSpec = { initialSize, targetSize ->
val spring = spring<Int>(visibilityThreshold = IntSize.VisibilityThreshold.height)
object: FiniteAnimationSpec<IntSize> {
override fun <V : AnimationVector> vectorize(converter: TwoWayConverter<IntSize, V>): VectorizedFiniteAnimationSpec<V> {
return spring.vectorize(object : TwoWayConverter<Int, V> {
override val convertFromVector: (V) -> Int
get() = {
converter.convertFromVector(it).height }
override val convertToVector: (Int) -> V
get() = {
converter.convertToVector(IntSize(maxOf(targetSize.width, initialSize.width), it))
}
})
}
}
}
)
)
},
) {
if (it) {
Text("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.")
}
}
but it still scales up from the left top corner
I think i do not understand how vectorize
worksVaibhav Jaiswal
01/18/2024, 11:04 AMModifier.animateContentSize()
Radoslaw Juszczyk
01/18/2024, 11:04 AMVaibhav Jaiswal
01/18/2024, 11:22 AMfillMaxWidth()
, it would take full width and hence animate only heightRadoslaw Juszczyk
01/18/2024, 11:51 AMRadoslaw Juszczyk
01/18/2024, 11:51 AMDoris Liu
01/18/2024, 6:28 PMAnimatedVisibility
would be much simpler to do the job. With AnimatedVisibility, I'd specify:
enter = expandVertically(expandFrom = Alignment.Bottom)
and exit = shrinkVertically(shrinkTowards = Alignment.Bottom)
Perhaps you intend to swap in other content with the use of AnimatedContent
? You could also disable the size animation in AnimatedContent by sizeTransform = null
, and use the enter and exit I mentioned above to achieve the same effect.