开发者

How to Remove Drawn Line in Android

开发者 https://www.devze.com 2023-02-28 19:15 出处:网络
Now i am doing one Puzzle. want to match the 开发者_Go百科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 fun

Now i am doing one Puzzle. want to match the 开发者_Go百科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.


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:

  • Draw the same line again using background color to "erase it"
  • Re-draw the whole screen again but without drawing lines this time


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号