【发布时间】:2019-06-03 19:55:38
【问题描述】:
这是我的主视图,我在第二个子视图中有图像。我遇到的问题是,我希望该视图组件中的图像填充剩余空间,但没有运气。知道如何实现吗?我尝试在高度和宽度上都使用 null,但它根本没有显示任何图像。 resizeMode="cover" 也不起作用。 flex 属性适用于其他视图,但不适用于图像,不知道为什么。
<View style={{flex:1}}>
<ProgressBar progress={0.3} width={width} color={"#ff0000"} />
<View style={{flexDirection: 'row', marginTop: 10, alignItems: 'center', flex: 0.2}}>
<Image style={styles.userImageStyle} source={{uri: item.item.userImage}} />
<Text style={{marginLeft: 10}}>
{item.item.username}
</Text>
</View>
<View style={{flex: 0.8, marginTop: 20}}>
<Image style={{width: null, height: null, flex:1}} resizeMode="cover" source={{uri: item.item.posts[0].imageUrl}} />
</View>
</View>
【问题讨论】:
-
确实给出了静态 { height: 150 and width:150 } (比方说)显示图像?
-
是的,它给了。但不知道如何用剩余的高度填充窗口的其余部分!
标签: react-native