我想从 react-native-elements 设置一张卡片,它有一张图片和卡片的标题。我希望图像占据视图中可用的整个宽度并调整高度以保持纵横比。所以基本上我既没有高度也没有宽度。
据我了解,图像组件需要高度/宽度道具。但是设置它不会使其响应。我用 flex 尝试了一些东西,但它不起作用
<Card>
<Image
style={{
flex: 1,
alignSelf: 'stretch',
width: null,
height: null
}}
resizeMode="contain"
source={{
uri: "url-of-the-image.png"
}}/>
<View>
<Text>Image Title</Text>
</View>
</Card>
图片未显示