在我的 React Native 应用程序中,我有以下代码:
<View style={{flex: 1}}>
<View style={{backgroundColor: 'black', height: 50}}/>
<ScrollView style={{borderWidth: 1, borderColor: 'red', flex: 1}}>
<Text style={{
borderWidth: 1,
borderColor: 'blue',
flexGrow: 1
}}>aaa</Text>
<Text style={{
borderWidth: 1,
borderColor: 'blue',
flexGrow: 1
}}>bbb</Text>
</ScrollView>
</View>
请注意,我flexGrow: 1
在aaa
和bbb
<View>
S中,但不长,填补了垂直空间。如果我交换<ScrollView>
a <View>
,孩子们会填写它。为什么是这样?
看看ScrollView
这里的文档:https : //facebook.github.io/react-native/docs/scrollview.html#contentcontainerstyle
您缺少的关键是指定容器样式应该是什么。维护人员不会对您的期望做出任何假设,特别是因为根据您过去的经验可能会令人困惑。你绝对可以得到你想要的工作。
这是添加到您的代码中的示例:https : //snack.expo.io/SkeLDj4EH
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句