How do you animate the height in react native when you don't know the size of the content?

后端 未结 4 1865
逝去的感伤
逝去的感伤 2021-01-03 17:16

In react-native, how do you animate the size of a View when you dont know the size of it\'s contents?

Let\'s say the View\'s content height can be

4条回答
  •  悲&欢浪女
    2021-01-03 18:10

    I use LayoutAnimation for that, just before the state change that causes your component's height to change, add:

    LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);

    You can use different presets:

    • spring
    • easeInEaseOut
    • linear

      You can read more about it here https://facebook.github.io/react-native/docs/layoutanimation.html

提交回复
热议问题