Android - can you make an object drawn in a canvas that you can click

I know that the canvas in android is the surface of the lower level of drawing, but Im currently draws all my objects inside the canvas, and I would like the best way to handle clicks for every object on the canvas. Ive tried matching x and y through the view they drew, and this only works for a while.

In any case, to make individual bitmaps Im im im im canvas clickable. The objects in my application are moving dynamically ... think of a game object where screen elements move. Ive tried to create a class that extended the Button, but everything was drawn in the upper right corner of the screen, so I'm not sure if you can move objects on the screen that extend the button, but at least when I clicked the image on top of the stack from them it gave the expected answer. Right now I am registering clicks on the screen through the view that the canvas is drawn inside and through the cycle of the loop that makes the action take place on the screen, I have an array of all the elements, and when the click is registered, I look through all the elements and those that are checked on the screen their coordinates. if i get a matchI shoot the intention to perform some action ..... as if I said that at best it is unreliable, and Im instantly lost how to restructure everything in order to get reliable answers.

+5
source share

All Articles