首页 > 解决方案 > 在视图中调整图像大小

问题描述

我的样式代码如下:

advertiseBox:{
    flexDirection: 'row-reverse',
  },
  advertiseImage:{
    alignItems: 'flex-start',
    resizeMode: 'contain',
    height: 200,
    width: 300,
    borderRadius: 7,
  },

调用图像和样式如下:

<View style={[todayStyles.advertiseBox, {backgroundColor: 'blue'}]}>

  <Image source={require('../../assets/images/advertise.png')} style={todayStyles.advertiseImage}/>

</View>

在代码中很明显没有使用边距和填充。为什么图像与顶部、底部和右侧有距离。问题的解决方案是什么?

在此处输入图像描述

标签: reactjsreact-native

解决方案


据此, resizeMode似乎不适用于 React Native 0.57 版中的 PNG


推荐阅读