I have a class and I set the bounds like so:
tattoo.setBounds(getWidth() / 2 - zoomController - x, getHeight() / 2 - zoomController - y, getWidth()/ 2 + zoomController - x, getHeight()/ 2 + zoomController - y);
tattoo.draw(c);
I want to be able to perform an action when the user clicks within these bounds. What is the easiest way to check if the click is within the bounds?
Use the
Rectthat describes the drawable’s bounds and call thecontains(int x, int y)method on it, passing in the x and y touch coordinates. For example:Alternatively, you could create your own (static) helper method; the math is really basic. 🙂