graphics - Android getX/getY interleaves relative/absolute coordinates -
there lot of discussions of how motionevent.getx/.gety "unreliable" (or other terms) , should use raw versions of these calls coordinates.
on nexus 7, have discovered .getx/.gety reliably returning interleaved absolute , relative coordinates. in other words, given action_move event returns absolute coordinates when call .getx , .gety. next action_move event return relative coordinates on .getx , .gety calls.
this cannot accidental behavior. leads me believe there must way discern whether given action_move returning absolute or relative coordinates.
does know how check given motionevent object see if returning absolute vs. relative coordinates on .getx , .gety calls?
edit: per request, here's code. it's nothing special, grab coordinates , move view object:
public boolean ontouch(view v,motionevent event) { boolean bexitvalue = true; float fx; float fy; int iaction; iaction = event.getactionmasked(); if (motionevent.action_move == iaction) { fx = event.getx(); fy = event.gety(); v.setx(fx); v.sety(fy); log.d("",("x: " + fx + ", y: " + fy)); } else if (motionevent.action_down != iaction) { bexitvalue = false; } return(bexitvalue); }
the log.d call , standalone floats aren't necessary make code work, allow see interleaving of values in logcat window.
i have found out, on galaxy s 4 gety , getrawy both wrong. change in orthogonal way. can right value following code:
rawy = event.getrawy() - spaceoverlayout; normaly = event.gety(); y = 0f; float prozentposition = ((rawy + normaly) / 2) / height; y = (normaly * (1 - prozentposition)) + (rawy * prozentposition);
hopefully help.
Comments
Post a Comment