react-native - React Native:为什么不设置 flexGrow在一个里面工作?
问题描述
在我的 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
and aaa
s bbb
<View>
,但它们不会增长以填充垂直空间。如果我将 a 换成<ScrollView>
a <View>
,孩子们会填满它。为什么是这样?
解决方案
看看ScrollView
这里的文档:https ://facebook.github.io/react-native/docs/scrollview.html#contentcontainerstyle
您缺少的关键是指定容器样式应该是什么。维护人员不会对您的期望做出任何假设,尤其是因为根据您过去的经验,它可能会让人感到困惑。你绝对可以得到你想要的工作。
这是添加到您的代码中的示例:https ://snack.expo.io/SkeLDj4EH
推荐阅读
- c# - .NET 密码学中 SignData() 和 CreateSignature() 之间的区别
- python - Sphinx api-doc 没有将包放在一起
- java - 单例设计模式中的Java静态对象范围不抛出空指针异常
- intellij-idea - 在项目工具窗口中按范围过滤?
- python - Pandas 索引插值在最后一个数据点之后填充缺失值
- c# - 如何在 C# 中创建一个循环遍历多个列表的循环
- c# - 为什么将字符串从 C# 传递到 C++ dll 得到 NULL?
- python-3.x - 使用 PDAL 进行点云去噪
- json - 在 API 网关中将 DynamoDB 数据格式化为普通 JSON
- python - 将数据加载到 CNN LSTM 模型 keras 时索引超出范围