使用反应本机灯箱时,图像会在屏幕左侧弹出,但大小与图像组件中定义的大小相同。
我希望图像以比以前更大的尺寸在屏幕中央弹出。
这是我的代码:
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>
)
}
<TouchableOpacity> style={{ margin: 5, width: width / 3 - 17, height: 110 }}
<Lightbox>
<Image
source={{ uri: image }}
style={{ width: 500, height: 500 }}
resizeMode='center'
/>
</Lightbox>
</TouchableOpacity>