Android: ScrollView content container doesn't animate to new layout
See original GitHub issueDescription
If the content in an Animated.ScrollView is using a layout transition, and transitioning from a larger height to a smaller height, the content container within the Animated.ScrollView jumps to the new height (instead of transitioning). This results in the content of the scroll view being clipped.
I’m only able to replicate this on Android, iOS seems to work fine.
Expected behavior
I would expect the layout of the content container to transition with the content on Android, as it does on iOS.
Actual behavior & steps to reproduce
https://user-images.githubusercontent.com/1010583/145732568-182c2f36-f68a-46d0-b55c-6691c94e9200.mp4
Snack or minimal code example
Note the layout prop on Animated.View below
import React, {useState} from 'react'
import {Button, SafeAreaView, StyleSheet} from 'react-native'
import Animated, {Easing, Layout} from 'react-native-reanimated'
export function randomIntFromInterval(min: number, max: number) {
return Math.floor(Math.random() * (max - min + 1) + min)
}
const App = () => {
const [height, setHeight] = useState(200)
return (
<SafeAreaView style={styles.container}>
<Animated.ScrollView style={[styles.container]}>
<Button
title="Random height"
onPress={() => {
setHeight(randomIntFromInterval(200, 600))
}}
/>
<Animated.View
layout={Layout.duration(240).easing(Easing.inOut(Easing.ease))}
style={{backgroundColor: 'teal', height}}
/>
</Animated.ScrollView>
)
</SafeAreaView>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
})
export default App
Package versions
- React Native:
0.66.3 - React Native Reanimated:
2.3.0 - NodeJS:
- Xcode:
- Java & Gradle:
Affected platforms
- Android
- iOS
- Web
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Scrollview doesn't scroll after resizing it's child using animation
I have a LinearLayout inside a ScrollView. At some point I collapse and expand the LinearLayout. After that the scrollview does scroll. Any ......
Read more >ScrollView - React Native
Component that wraps platform ScrollView while providing integration with touch locking "responder" system.
Read more >Reveal or hide a view using animation - Android Developers
This animation is useful for situations where you want to switch content or views in your app. The crossfade animation shown here uses ......
Read more >overscroll-behavior - CSS: Cascading Style Sheets | MDN
If you have overscroll-behavior: contain; selected, the outer container will not scroll unless you move your cursor out of the inner container ...
Read more >Handling Scrolls with CoordinatorLayout - CodePath Cliffnotes
So long as the CoordinatorLayout is used as the primary layout, this animation effect will occur for you automatically. The floating action button...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hey, I resolved the problem. You just need to use https://reactnative.dev/docs/scrollview#contentcontainerstyle
Without this view was cropped by the parent component.
working code
Thanks much! Will give this a shot!