3

How do I add duration to content size change animation in Jetpack Compose? Trying to use Modifier.animateContentSize() and pass an animationSpec with duration, but it just snaps in or out, duration is not observed.

Column() {
     Modifier.animateContentSize
       (animationSpec = tween(durationMillis = 5000,
       easing = LinearEasing))
     if (!isTabInvisible) {
             //some content goes here
                                
      }
 }
             
Dmitri
  • 2,563
  • 1
  • 22
  • 30

1 Answers1

2

I suggest you use animateDpAsState, instead animateContentSize:

val animatedSize by animateDpAsState(
    targetValue = /*condition Here*/, animationSpec = tween(
        durationMillis = 5000,
        easing = LinearEasing
    )
)