https://kotlinlang.org logo
#compose
Title
# compose
m

Mohammad Sianaki

10/02/2021, 1:28 PM
Hi, How Can I animate a
Text
between two
TextStyle
?
m

Marko Novakovic

10/02/2021, 1:31 PM
recently I animated
fontSize
and color together:
Copy code
val transition = updateTransition(targetState = isSelected, label = "")
    val color by transition.animateColor { selected ->
        if (selected) Color.Black else Color.LightGray
    }
    val fontSize by transition.animateInt { selected ->
        if (selected) 24 else 16
    }
Text(
            text = label,
            fontSize = fontSize.sp,
            color = color,
        )
something like this
maybe that can help you
OR you can maybe use
AnimatedContent
with and define some custom animation
m

Mohammad Sianaki

10/02/2021, 1:37 PM
thanks, any idea how to animate beween two material typography?
m

Marko Novakovic

10/02/2021, 1:38 PM
AnimatedContent
is the only thing that comes to mind right now
or you can create your own custom animation and provide
Copy code
TwoWayConverter
am not aware of that exiting out of the box
4 Views