Sunday 15 February 2015

android - Touch event for visible part of the Image -


I need to apply the click / touch event only for the visible part of the scene. For example, a 200x200 size Say the image except the center 50X50, the remainder is transparent. I want to get touch events only for the 50X50 scene portion, not the remaining transparent part.

Enter image description here

in the image above ( Its single image), only internal diamond has got a visible part. In addition to Diamond Transparent Terrain. So, if I touch the diamond, then I want to do something else.

Edit:

Rachita's links helped me through that link and I came to know how I can apply but I did not understand some constants like 320, 240 etc. while creating points. In my case, I know Diamond (in the image above) X and Y poniat (the rigid coded values ​​are reality). So, how can I determine whether I've touched Diamond or outside?

My Diamond Points are given below

  pointA = new point (0, 183); Pointb = new point (183, 0); Point C = new point (366, 183); Point = new point (183, 366);   

Edit:

Finally found a solution from the point, depending on its probe point pixel color was touched. If color 0 means, you touched the transparent layer and you touched some colorful part of the image. Simple, but very effective see it.

AFAIK You can not apply it to click listener or any other direct way of me

  • > Calculate the area in which your diamond will be captured (you should see the size of the image to calculate the diamond area)

    3.TouchListener only trigger a task when x, y fall into the required area

    edit

    Andrew >

    Please refer to this link

      display mdisp = getWindowManager (). GetDefaultDisplay (); Int maxX = mdisp.getWidth (); Int maxY = mdisp.getHeight ();   

    (x, y): -

    1) (0,0) is the top left corner.

    2) (max, 0) top right corner

    3) (0, max) bottom left corner

    4) (max, max) below The right corner is

    The maximum height and width of the maximum screen screen here is in pixels, which we have received in the given code.

    Remember If you want to support multiple devices with different screen sizes, make sure that you

    check That touch point is contained in the required polygon P> I think this link can help you decide what touched the point (You can get X, Y, Touch Event eg.event.getX ()) in the required polygon whose issue you gave in the question Land. And

  • No comments:

    Post a Comment