简体   繁体   English

在 React Native 中使用 Draggable 组件时,图像边缘被裁剪

[英]Image is getting cropped in edges while using with Draggable component in React Native

I am using react-native-draggable for the drag and drop of an image in an android application.我正在使用react-native-draggable在 android 应用程序中拖放图像。 The drag and drop work perfectly but the image size is getting cropped out.拖放操作完美,但图像尺寸被裁剪掉了。

For the vertical images some part of the top and bottom is getting cropped and for horizontal photos left and right side of the image getting cropped out.对于垂直图像,顶部和底部的某些部分会被裁剪,对于水平照片,图像的左侧和右侧会被裁剪掉。 I have tried changing the render size and position but it's still getting cropped.我已经尝试更改渲染大小和 position 但它仍然被裁剪。

I really appreciate it if anyone can help on this issue.如果有人可以帮助解决这个问题,我真的很感激。

Sharing the following snippet for the drag and drop共享以下代码片段以进行拖放

 <Draggable
          imageSource={route.params.url}
          renderSize={230}
          x={130}
          y={90} />

I have figured out a way for this issue, instead of giving the image as a source in the draggable component, I have created an Image widget with the image URI and placed that Image widget inside the draggable which eventually solve the crop issue.我已经找到解决此问题的方法,而不是将图像作为可拖动组件中的源,我创建了一个带有图像 URI 的图像小部件,并将该图像小部件放置在可拖动组件中,最终解决了裁剪问题。 Following is the source code.以下是源代码。

 <Draggable
          maxX={MOBILE_WIDTH}
          maxY={MOBILE_HEIGHT}
          minX={0}
          minY={0}
          x={FRAME_XPOSITION}
          y={FRAME_YPOSITION}>
          <Image
            source={route.params.url}
            size="2xl"
            alt="Image"
            resizeMode="contain"
            resizeMethod="scale"
          />
 </Draggable>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM