Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This took me days to sort out, and I don't think I could have ever figured it out without SO. Thanks especially to @Awais Tariq for giving me the clue needed here: <a href="https://stackoverflow.com/questions/7524843/get-canvas-coordinates-after-scaling-up-down-or-dragging-in-android">Get Canvas coordinates after scaling up/down or dragging in android</a>. Basically everything (movements, translations, and most importantly, <strong>checking against pointer positions</strong>) must run through a calculation that can translate the new screen density. Here's what I changed in case anyone in future runs into this mess:</p> <pre><code>liveRect.left = (startPos.x / scaleFactor + clipbounds.left) - width/2; liveRect.top = (startPos.y / scaleFactor + clipbounds.top )- height/2; liveRect.right = liveRect.left + width; liveRect.bottom = liveRect.top + height; </code></pre> <p>This recalcs the postions of the rects after a zoom. But the pointer is also 'off' exponentially as you go further from 0,0. To correct, I used the following formula inside the if-check to see what was touched:</p> <pre><code>if (r.contains(startPos.x / scaleFactor + clipbounds.left, startPos.y / scaleFactor + clipbounds.top)) </code></pre> <p>Everything is successfully working with this solution. I may go back and try this with a layout instead to see if passing in a view to the if-check might be easier. But, for now, this works. Way too complex for my newbie coder brain to figure this out, I wonder if this isn't something that could be built in to Android in future.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload