Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native ScrollView scrolling both directions

I'm trying to get a React Native ScrollView to scroll horizontally and vertically, but for some reason it won't do it. I know it doesn't work on Android, but it is supposed to work on iOS.

I've looked at this issue: https://github.com/facebook/react-native/issues/2962

And did what it suggested, but it still only scrolls one direction.

This is how I have it declared:

<ScrollView directionalLockEnabled={false} horizontal={true} style={styles.container}>
    {this.buildContent()}
</ScrollView>

Any ideas on how to get this to scroll both directions?

like image 408
Aaron Avatar asked Sep 22 '16 15:09

Aaron


2 Answers

There is currently not a direct way to achieve this. If setting contentContainerStyle prop is not a problem for you, you can go that way. If it is, you can always use 2 nested ScrollViews.

<ScrollView>
   <ScrollView horizontal={true}> 
      {this.buildContent()}
   </ScrollView>
</ScrollView>
like image 105
jankoritak Avatar answered Oct 19 '22 10:10

jankoritak


try this:

    <ScrollView
      maximumZoomScale={2}
      minimumZoomScale={1}
      style={{ width: 320 }}
      contentContainerStyle={{ width: 321 }}
    >
      <View style={{ width: 321, height: 320, backgroundColor: "green" }} />
    </ScrollView>

contentContainerStyle Doc here,the property supported officially from [email protected]

like image 31
Oboo Cheng Avatar answered Oct 19 '22 10:10

Oboo Cheng