【问题标题】:How to popup an image on press in react native如何在本机反应中弹出图像
【发布时间】:2019-03-01 04:59:36
【问题描述】:

我想在印刷机上放大图像。

这是我的代码

{
     this.state.data.file_name &&
     <Avatar
        xlarge
        source={{ uri: IMG_URL + this.state.data.file_name }}
        onPress={() => this.enlargeImage(IMG_URL + 
        this.state.data.file_name)}
        activeOpacity={0.7}
        containerStyle={{ borderWidth: 1, borderColor: '#000', margin: 10 }}
     />
}

enlargeImage = (img) => {
return (
  <Lightbox underlayColor="white">
  <Image
    style={{flex: 1,height: 200}}
    resizeMode="contain"
    source={{ uri: img }}
  />
 </Lightbox>      
)
}

现在点击图片没有反应。我正在使用react native lightbox。有没有其他方法可以在触摸时弹出图像?

【问题讨论】:

  • 您在寻找图像查看器吗?
  • 我只想在点击时放大图像以向用户显示完整图像。

标签: image react-native popup react-native-lightbox


【解决方案1】:

您必须将灯箱添加到主头像图像

例子:-

{this.state.data.file_name &&
          <Lightbox style = {{flex: 1}}>
            <Avatar
        xlarge
        source={{ uri: IMG_URL + this.state.data.file_name }}
        activeOpacity={0.7}
        containerStyle={{ borderWidth: 1, borderColor: '#000', margin: 10 }}
     />
          </Lightbox>
        }

你不需要在头像上添加新闻事件 灯箱会自动接受事件。

附加样式,可以使用灯箱的属性。

【讨论】:

  • 如何设置放大后的图片样式?现在图像以与以前相同的大小显示。
  • 请重新检查我的答案,因为我已经更新了答案
猜你喜欢
  • 2021-05-24
  • 1970-01-01
  • 1970-01-01
  • 2018-09-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-08-22
  • 1970-01-01
相关资源
最近更新 更多