Reputation: 5873
I have a react native component like:
import React, { Component } from 'react';
import { StyleSheet, Text, View, ScrollView } from 'react-native';
import Level from './Level';
class LevelList extends Component {
render() {
return (
<ScrollView style={styles.scrollView} >
<View style={styles.levelList}>
<Level />
<Level />
<Level />
<Level />
<Level />
<Level />
</View>
</ScrollView>
)
}
}
var styles = StyleSheet.create({
scrollView: {
backgroundColor: '#fff',
flex: 1,
},
levelList: {
marginTop: 50,
flexDirection:'column',
alignItems: 'center',
},
})
export default LevelList;
Here <Level>
is simply a component that holds a text.
I have <LevelList>
in my container like:
class LevelListView extends Component {
render() {
return (
<View style={{flex: 1}}>
<Header />
<LevelList />
</View>
)
}
}
export default LevelListView
Here I get a scrollbar in the side of my list but it does not get scrolled. What am I missing here ?
I am running the app in emulator:
Update:
import React, { Component } from 'react';
import { StyleSheet, Text, View } from 'react-native';
class Header extends Component {
render() {
return (
<View style={styles.toolbar}>
<Text style={styles.toolbarBack}>Back</Text>
<Text style={styles.toolbarTitle}>Levels</Text>
</View>
)
}
}
var styles = StyleSheet.create({
toolbar:{
backgroundColor:'#00bcd4',
paddingTop:10,
paddingBottom:10,
flexDirection:'row'
},
toolbarTitle:{
color:'#fff',
textAlign:'center',
fontSize:20,
fontWeight:'bold',
marginRight: 30,
flex:1
},
toolbarBack: {
color: '#fff',
fontSize: 14,
fontWeight: 'bold',
marginTop: 4,
marginLeft: 10,
}
})
export default Header;
Upvotes: 5
Views: 3924
Reputation: 203
I had the same problem and tried everything on the internet like flex:1 solutions... But the problem is, Android is not letting you use nested scroll with scrollview. I just put:
nestedScrollEnabled={true}
Command to my scrollview object and it worked like a charm.
Upvotes: 4
Reputation: 1
I had the similar problem but I resolved it by doing this:
<ScrollView style={{
height:Dimensions.get('screen').height
}}>
///
</ScrollView>
Upvotes: 0