如何删除 Android 中的绘制线
现在我正在做一个拼图。想要通过点匹配正确的配对。假设如果我们连接不匹配对,它想要显示警报并自动删除绘制的线。现在除了一件事之外所有功能都已完成。 我对删除绘制的线(自动)没有任何想法。
安卓上可以吗?有没有什么方法可以去除画线。
Now i am doing one Puzzle. want to match the Correct Pair Via Dots. suppose if we connect mismatch pair it want to show alert as well as automatically remove that drawn lines. Now all functionalties are completed except one thing.
i don't have any idea about remove drawn Line (automatically) .
Is it Possible in Android? Is there any method available to remove drawnline.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否使用
Canvas.drawLine
? api中没有“删除画线”这样的东西。我可以想象几个选项:
Are you drawing lines using
Canvas.drawLine
? There is no such thing in the api to "remove drawn line".I can imagine a couple of options:
如上所述,无法删除绘制的线。
您可以如何执行以下操作:
1) 使用 Bitmap.copy 制作原始图像的副本(原始图像 = img1;重复 = img2)。将其复制到 Config.ARGB_8888,使其可变。
2)使用canvas.drawLine()在新创建的图像上绘制线条
3)当你想回到没有线条的旧图像时,显示img1并回收img2。
然而,只有当您的映像不占用大量 RAM 时,这才有效,在这种情况下,您在同一个映像上执行所有操作并在想要回滚时下载新副本将是理想的选择。
As mentioned above there is no way to remove the drawn line.
How ever you can do the following:
1) Make a copy of the original image(original image = img1; duplicate = img2), using Bitmap.copy. Copy it to Config.ARGB_8888 which makes it mutable.
2) Draw lines on the newly created image using canvas.drawLine()
3) When you want to go back to your old image without lines, display img1 and recycle img2.
However this works only if your image doesnt take up a lot of RAM, in which case you doing everything on the same image and downloading a new copy when you want to rollback would be the ideal option.