如何拖动和调整 imageView 中的图像,然后用另一个 imageview 屏蔽该 imageview

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

我可以制作一个故事制作应用程序,我可以调用 json 以编程方式创建布局:我可以从图库中选择一个图像并使其掩盖所选对象。给我编码端的解决方案。我清楚地提到了我想要的示例图像。

sample image

[Frame][2]

android
1个回答
0
投票

您没有提供任何代码或 json 文件,所以我帮不上什么忙。 但是,如果您创建了类似于您提供的图像的布局,我假设您已经指定了蒙版的路径。

如果您有用户选择的图像的蒙版和位图(或可绘制)的路径,那么您可以在自定义视图的

Canvas.clipPath()
中使用
canvas.drawBitmap()
Drawable.draw()
(或
onDraw()
)。

示例:

override fun onDraw(canvas: Canvas?) {
    super.onDraw(canvas)
    clipPath.reset()
    // Set path of mask you want
    // clipPath.addOval(bound, Path.Direction.CW)
    canvas?.withClip(clipPath) {
        // Draw image to location you want
        // canvas.drawBitmap(bitmap, 0, 0, paint)
    }
}

再次强调,如果您需要更多帮助,您需要提供更多信息和您尝试过的事情。

© www.soinside.com 2019 - 2024. All rights reserved.