Reputation: 669
Im trying to make a scrollview inside a View in ReactNative. For some reason i cant scroll in the ScrollView.
render() {
return (
<View>
<View>
<Text>Top</Text>
</View>
<ScrollView >
<Text>Line 1</Text>
<Text>Line 2</Text>
<Text>Line 3</Text>
<Text>Line 4</Text>
<Text>Line 5</Text>
<Text>Line 6</Text>
<Text>Line 7</Text>
...
</ScrollView>
</View>
);
}
What is wrong here? Im testing on Android
Thanks, Magnus
Upvotes: 1
Views: 3750
Reputation: 56
don't forget to import scrollview from react native like this :import { Text, View, ScrollView } from 'react-native';
render() {
return (
<View style={styles.container}> // style in firstview
<View>
<Text>Top</Text>
</View>
<ScrollView contentContainerStyle={styles.Scroll}>// and give style in scrollview
<Text>Line 1</Text>
<Text>Line 2</Text>
<Text>Line 3</Text>
<Text>Line 4</Text>
<Text>Line 5</Text>
<Text>Line 6</Text>
<Text>Line 7</Text>
</ScrollView>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'orange',
justifyContent: 'center',
// alignItems: 'center'
},
Scroll: {
height: 1000,
paddingVertical: 30,
}
});
Upvotes: 2