首页 > 解决方案 > 反应原生 Android 图像在 resizeMode:'contain' 上模糊

问题描述

我正在使用虚拟设备在 Android Studio 上测试 react-native 应用程序,我在包含的图像的背景上得到了这些模糊标记。它在 iOS 上运行良好,但在 Android 上看起来不一样。

(问题图片)https://i.redd.it/qoptkvhzbct21.png

我已经尝试更改图像的背景颜色,但它并没有改变。

<View style={styles.imageContainer}>
   <Image 
     source={{ uri: `https://devUrl/${this.props.image}`}} 
     style={{ 
       flex: 1,
       width: null,
       height: null,
       resizeMode: 'contain',
       borderWidth: 1,
       borderColor: 'transparent',
       borderRadius: 10, 
     }} 
    />
</View>   

styles.imageContainer: {
    height: 500,
    flexDirection: 'row',
    borderTopRightRadius: 10,
    borderTopLeftRadius: 10,
    paddingTop: 0,
    paddingLeft: 0, 
    paddingRight: 0, 
    backgroundColor: 'white'
  },

编辑:原来这是一个问题,你不能在 Android 设备上使用 resizeMode: 'contain' 。我使用图像的纵横比并设置容器高度。

标签: androidreact-native

解决方案


推荐阅读