Let's assume an ImageView, which when added to my layout(relative layout), with no scaling(the scale is 1). If I call getX(), it returns the correct X position.
However, if I now call setScaleX() with 2, and then call getX(), I get a totally different value. If I divide this value by the scale factor(2), it still doesn't give me the actual position. How do I get the actual position? Why is getX() returning absurdly large values which keep growing when the ImageView is scaled?
This is the case for the Y coordinate as well.
Instead of using getX() and getY() to get the position of the view, I'm now using getMatrix(), and obtaining the translation values from this matrix. This seems to work well! It reports the correct X and Y values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With