【问题标题】:Rounded corner issue with GIF image in react native androidreact native android中GIF图像的圆角问题
【发布时间】:2017-03-20 16:14:18
【问题描述】:

我是 react native 的新手,我在列表视图中显示 GIF 图像列表,我尝试用普通图像执行此操作,并且它正在工作,但使用 GIF 图像它不工作我现在不为什么。

我使用下面的样式和代码来圆角。

  <ListView contentContainerStyle={styles.list}
  showsHorizontalScrollIndicator={false}
  horizontal= { true }
  dataSource={this.state.dataSource}
   ref={ref => this.listView = ref}
  renderRow={(rowData) => {
    return (
      <TouchableOpacity style={styles.item} onPress={() => this.stickerSelected(rowData)}>
          <Image style={styles.image} source={this.props.images[rowData].src}/>
      </TouchableOpacity>
    )
  }}
  />



list: {
justifyContent: 'center',
flexDirection: 'column',
backgroundColor: '#FFFDEB',
flexWrap: 'wrap',
paddingLeft: 6,
paddingRight: 6


},
  item: {
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#EAD62F',
    borderRadius: 10,
    margin: 3,
    width: 75,
    height: 75,
  },
  image: {
    width: 75,
    height: 75,
    borderRadius: 10,
  }

并尝试在图像和项目样式中添加以下属性以解决重叠问题,但角仍为方形。

 overflow: 'hidden',

【问题讨论】:

    标签: android react-native gif


    【解决方案1】:

    您需要设置overlayColor 样式。它在这里描述https://facebook.github.io/react-native/docs/image.html#style

    image: { width: 75, height: 75, borderRadius: 10, overlayColor: 'white', }

    【讨论】:

    • 还有其他方法吗?因为我的 gif 位于多色图案背景之上。所以我不能给它一个坚实的overlayColor。
    • 谢谢!这对我有帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-10
    • 1970-01-01
    • 1970-01-01
    • 2019-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多