【发布时间】:2018-08-15 09:15:37
【问题描述】:
当视图被放置在滚动视图中以进行本机反应时,为什么 flexDirection 不起作用?
当我的视图没有放在滚动视图中时,参数 flexDirection: 'row' 可以正常工作。
export default class ProfileScreen extends Component {
render() {
return (
<View style={{flex: 0.1, flexDirection: 'row', justifyContent: 'flex-start', height:70}}>
<View style={{flex:0.2, backgroundColor: 'red'}} />
<View style={{flex:0.8, backgroundColor: 'skyblue'}} />
<View style={{flex:0.2, backgroundColor: 'steelblue'}} />
</View>
);
}
当它被放置在滚动视图中时,参数 flexDirection 不再起作用。
export default class ProfileScreen extends Component {
render() {
return (
<ScrollView stickyHeaderIndices={[0]} >
<View style={{flex: 0.1, flexDirection: 'row', justifyContent: 'flex-start', height:70}}>
<View style={{flex:0.2, backgroundColor: 'red'}} />
<View style={{flex:0.8, backgroundColor: 'skyblue'}} />
<View style={{flex:0.2, backgroundColor: 'steelblue'}} />
</View>
<View style={{flex: 1, flexDirection: 'row', height: 10}} />
<View style={{flex: 1, flexDirection: 'row', height: 200, backgroundColor: 'skyblue'}} />
<View style={{flex: 1, flexDirection: 'row', height: 10}} />
</ScrollView>
);
}
}
【问题讨论】:
-
你必须使用 react 文档的 contentContainerStyle
标签: css react-native flexbox scrollview