我想知道是否可以调整图像的大小以使其适合 View 。
这是我现在拥有的
<View style={styles.container}>
<View style={styles.header}>
<Image
source={headerImage}
/>
</View>
<Text style={styles.basicText}>text</Text>
</View>
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff"
},
header: {
height: 200,
backgroundColor: 'red'
},
background: {
width: null,
height: null
},
image: {
}
我想让图像适合标题 View 。
最佳答案
添加到 Moti Azu 的答案中,您还需要设置 resizeMode。
image: {
flex:1,
height: null,
resizeMode: 'contain',
width: null,
}
如果它似乎不起作用,请确保您的 View
样式 container
具有宽度。
关于android - 将图像调整为 View - native react ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44883098/