react-native: [Android] ScrollView clips children even with overflow: 'visible'

Description

Child elements of ScrollView are clipped when positioned outside of the ScrollView bounds, even when the style and contentContainerStyle props have been given overflow: 'visible'.

React Native version:

System: OS: macOS 10.15.7 CPU: (12) x64 Intel® Core™ i7-9750H CPU @ 2.60GHz Memory: 538.14 MB / 16.00 GB Shell: 5.7.1 - /bin/zsh Binaries: Node: 12.18.0 - ~/.nvm/versions/node/v12.18.0/bin/node Yarn: Not Found npm: 6.14.4 - ~/.nvm/versions/node/v12.18.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.10.1 - /Users/rickard/.rbenv/shims/pod SDKs: iOS SDK: Platforms: iOS 14.2, DriverKit 20.0, macOS 11.0, tvOS 14.2, watchOS 7.1 Android SDK: API Levels: 28, 29, 30 Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.0, 30.0.2 System Images: android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom Android NDK: Not Found IDEs: Android Studio: 4.0 AI-193.6911.18.40.6514223 Xcode: 12.2/12B45b - /usr/bin/xcodebuild Languages: Java: 11.0.7 - /Users/rickard/.jenv/shims/javac Python: 3.9.1 - /Users/rickard/.pyenv/shims/python npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: 0.63.3 => 0.63.3 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Expected Results

Given that overflow: visible is set on both the style and contentContainerStyle props on the ScrollView the overflowing children of the ScrollView should be visible.

Snack, code example, screenshot, or link to a repository:

https://snack.expo.io/Xw1c66W8R

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 10
  • Comments: 16 (2 by maintainers)

Commits related to this issue

Most upvoted comments

@kneza23 @sxyshirly @nofacez

If you are using overflow property inside a scroll view or flatlist, add this prop to your scrollview or flatlist

removeClippedSubviews(false)

On Android the default value is true which obstructs it from rendering extra content.

@19BCS1114 Your solution does not seem to work for the Author’s snack: https://snack.expo.io/Xw1c66W8R

Just add the prop removeClippedSubviews={false} to the ScrollView and you’ll see it does not change the UI at all. I checked on an Android device too

Not ideal, for the time being I’m using this workaround to have a scrollable overflowing container:

<FlatList
  data={undefined}
  renderItem={undefined}
  ListHeaderComponent={
    <View style={styles.overflowing}>
      ...
    </View>
  }
/>

@kneza23 @sxyshirly @nofacez

If you are using overflow property inside a scroll view or flatlist, add this prop to your scrollview or flatlist

removeClippedSubviews(false)

On Android the default value is true which obstructs it from rendering extra content.

In my case, the issue was because I set width: screenWidth in contentContainerStyle and when I remove contentContainerStyle, and add a view inside with that style, it working.

.....
        <ScrollView
          // contentContainerStyle={styles.scrollViewContent} //=> remove this
        >
          <View style={styles.scrollViewContent}> {/*add this*/}
          {/*some contents*/}
          </View>
        </ScrollView>

.....
const styles = StyleSheet.create({
  scrollViewContent: {
    flexGrow: 1,
    width: screenWidth,
    overflow: 'visible',
  },

});