i need map ontouch event's x, y coordinates bitmap x, y coordinates inside imageview use following approach.
however approach seems work when either:
a) zoom image (all way in)
b) works in case if make application full screen
final int index = event.getactionindex(); touchlocation = new float[] { event.getx(index), event.gety(index) }; matrix matrix = new matrix(); imageview view = getimageview(); view.getimagematrix().invert(matrix); matrix.posttranslate(view.getscrollx(), view.getscrolly()); matrix.mappoints(touchlocation); // touchlocation[0] real x , [1] real y however activity actionbar activity @ bit wrong position on y axis. tried deducting height of actionbar , statusbar not work.
what odd on full screen not matter if zoom image in or out correct coordinates calculated other activity type not map points correctly.
i use code axis of touch on screen:
pointf p = new pointf(event.getx(), event.gety()); view v = this;// view view root = v.getrootview(); while (v.getparent() instanceof view && v.getparent() != root) { p.y += v.gettop(); p.x += v.getleft(); v = (view) v.getparent(); } hope works well
Comments
Post a Comment