Reputation: 61
Scroll view not scrolling
Example that I'm trying on Expo:
<View style={{flex: 1}}>
<ScrollView
contentContainerStyle={{ flexGrow: 1 }}>
<View style={{ flex: 1, flexDirection: 'row', flexWrap: 'wrap' }}>
<Item />
<Item />
<Item />
<Item />
<Item />
<Item />
</View>
</ScrollView>
</View>
Upvotes: 2
Views: 5626
Reputation: 597
The problem is that in Android other touchable steals user’s touch event that's why you can not scroll the ScrollView but many times it works as expected on IOS platform. I guess you just need to add onStartShouldSetResponder={() => true}
to the View which wraps the intended ScrollView. Can you please try below code:
<View onStartShouldSetResponder={() => true}>
<ScrollView>
<View style={{ flex: 1, flexDirection: 'row', flexWrap: 'wrap' }}>
<Item />
<Item />
<Item />
<Item />
<Item />
<Item />
</View>
</ScrollView>
</View>
I hope this helps!
Upvotes: 3
Reputation: 951
Can you try this?
<View style={{flex: 1}}>
<ScrollView
style={{ flex: 1 }}>
<View style={{flexDirection: 'row', flexWrap: 'wrap' }}>
<Item />
<Item />
<Item />
<Item />
<Item />
<Item />
<Item />
<Item />
<Item />
<Item />
<Item />
<Item />
</View>
</ScrollView>
</View>
If the content total height is greater than the scroll view, then only the scroll view will scroll.
Upvotes: 0
Reputation: 320
Maybe you can add flex: 1 on ScrollView
If doesnt work you can try make something like this:
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
ScrollView
} from 'react-native';
export default class App extends Component {
render() {
return (
<ScrollView>
<Text style={styles.welcome}>Welcome to React Native</Text>
<Text style={styles.welcome}>Welcome to React Native</Text>
<Text style={styles.welcome}>Welcome to React Native</Text>
<Text style={styles.welcome}>Welcome to React Native</Text>
<Text style={styles.welcome}>Welcome to React Native</Text>
<Text style={styles.welcome}>Welcome to React Native</Text>
<Text style={styles.welcome}>Welcome to React Native</Text>
<Text style={styles.welcome}>Welcome to React Native</Text>
<Text style={styles.welcome}>Welcome to React Native</Text>
</ScrollView>
);
}
}
const styles = StyleSheet.create({
welcome: {
flex: 1,
margin: 20,
backgroundColor: 'orange',
margin: 10,
textAlign: 'center',
fontSize: 20,
paddingTop: 70,
}
});
Upvotes: 1