java - How can I set touchEvent areas on a TouchImageView in function of a pinchZoom in androidStudio? -
i'm programming mobile application needs show shapes (rectangles , circles) on image. managed draw shapes on image, i've added zoom system (pinchzoom , double tap zoom) , finally, i've implemented touchevents on shapes drawn on image. here's problem, when image not zoomed, can tap on shapes, touchevents working perfectly. but, when image zoomed, touchevent areas of shapes stay fixed @ coordinates of shapes when there no zoom... touchevent areas don't "move" zoom in order stay on shapes.
do have idea how fix problem ?
pimageview.setontouchlistener(new view.ontouchlistener(){ @override public boolean ontouch(view v, motionevent event) { if(event.getaction() == motionevent.action_down){ double x = event.getx(); double y = event.gety(); float zoom = pimageview.getcurrentzoom(); for(int i=0;i<shapes.size();i++) { if (shapes.get(i).contains(x,y,zoom)) { listener.ontouch(shapes.get(i)); } } } return true; } }); return pimageview;
Comments
Post a Comment