我从 Facebook API 获取一些图像,我想以响应式显示它们,为 100% 宽度和自动高度。问题似乎是 React Native 裁剪了我的图像。
我尝试了这些解决方案:
另外,我尝试使用 react-native-auto-height-image 并将其宽度设置为屏幕的宽度。
实际代码:
<TouchableOpacity onPress={() => Linking.openURL(post.url)}>
<Card style={{ flex: 1 }}>
<CardItem>
<Left>
<Thumbnail source={ThumbnailImage} />
<Body>
<Text>My text</Text>
<Text note>{createdTime}</Text>
</Body>
</Left>
</CardItem>
<CardItem>
<Body>
<AutoHeightImage
width={Dimensions.get('window').width - 35}
source={{ uri: post.media.image.src }}
/>
<Text style={{ marginTop: 10 }}>{post.description}</Text>
</Body>
</CardItem>
</Card>
</TouchableOpacity>
PS:应用程序使用 Native Base 作为 UI 库。