使用灯箱自动弹出图像

问题描述 投票:0回答:1

使用反应本机灯箱时,图像会在屏幕左侧弹出,但大小与图像组件中定义的大小相同。

我希望图像以比以前更大的尺寸在屏幕中央弹出。

这是我的代码:

 return (
  <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
    <Button
      title="Pick an image from camera roll"
      onPress={this._pickImage}
    />


    <Lightbox onPress={() => this.enlargeImage(image)} >
      {/*    <TouchableOpacity onPress={() => this.enlargeImage(image)}> */}
      <Image
        source={{ uri: image }}
        style={{ width: 200, height: 200 }}
      />
      {/* </TouchableOpacity> */}
    </Lightbox>

当我按下图像时,我想以屏幕的新尺寸返回图像:

 enlargeImage = (image) => {
  return (
  <Lightbox>
    <Image
      source={{ uri: image }}
      style={{ width: 500, height: 500 }}
      resizeMode='center'
    />
  </Lightbox>
)
}
reactjs image react-native lightbox
1个回答
0
投票
<TouchableOpacity> style={{ margin: 5, width: width / 3 - 17, height: 110 }} <Lightbox> <Image source={{ uri: image }} style={{ width: 500, height: 500 }} resizeMode='center' /> </Lightbox> </TouchableOpacity>
© www.soinside.com 2019 - 2024. All rights reserved.