I tried to move an ImageView on touch events by this code:

http://pastebin.com/Wr033FfP

At first, everything worked well on Nexus 5 (Android 4.4.4 and Lollipop). 
But then I tried on older versions of Android like 4.0.4(Galaxy S2) or 
Nexus S(4.1.1)... and none of them worked.

Then after struggling for a while, I came up with this solution and it 
worked well on all devices:

(Notice that now, I keep track of the ImageView's matrix object by a local 
object instead of getting it via ImageView's getImageMatrix())

http://pastebin.com/UyrwivAh

I got the solution but I still couldn't get why my former code didn't work?!

I tried to research but the only thing made sense was the documentation of 
ImageView's getImageMatrix():

Return the view's optional matrix. This is applied to the view's drawable 
when it is drawn. If there is no matrix, this method will return an 
identity matrix. Do not change this matrix in place but make a copy. If you 
want a different matrix applied to the drawable, be sure to call 
setImageMatrix().

Then it made me more confused by saying Do not change this matrix in place 
but make a copy, what's the point of doing so? why can't I just do like I 
did in the former code? (get the current matrix of the ImageView then apply 
translation, then set it back via setImageMatrix() as the documentation 
says)

Someone please shed me some light, this is too much confusion for me.


-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to