I create class that extends LinerLayout and add many elements on view, also I add circle with
etc canvas.drawCircle(100, 100, 10) and when I implement onTouchEvent I am not sure how to redraw only that element(circle). which parameters to set in “Rect” so I can send it to invalidate(Rect).
Thanks.
For the specific example, I think this code example does what you want. I moved your coordinates into variables (cx, cy, r) just to make it clear. Based on what you mentioned, I think you would call this from within your LinearLayout subclass.
I added an extra pixel on all sides just to overlap the circle a bit to ensure the entire area is invalidated. Based on my experience, it looks like you can include negative values or values that exceed the dimensions of the canvas.