Get position of imageview on layout android
26,126
Solution 1
You can use this with getLocationOnScreen(int [])
Solution 2
x = imageViewObject.getLeft();
y = imageViewObject.getTop();
Hope, it help you!
Solution 3
At runtime you can get the location of every View
object (this includes Layouts
too) with
Left Position of View Object getleft()
Top Position of View Object getTop()
Right Position of View Object getRight()
Bottom Position of View Object getBottom()
Even you can get the location with
getLocationOnScreen(int [] )
Solution 4
Position meaning x and y and height and width?
This layout is a view, that view has these properties.
Comments
-
Programmer about 4 years
Please help me i want to get position of imageview on a layout.
-
Programmer over 12 yearsi want to get current location on view means x and y corrdinate, so that i can animate from this position to that position.
-
JoxTraex over 12 yearsLook at the methods available in the View class.
-
mathheadinclouds over 9 yearsdidn't work for me. Everything returned zero. (Used with Button, not ImageView, but that shouldn't make a difference.)
-
Lasitha Lakmal over 4 yearsnot work for me. my image with is in a RelativeLaoyout and it relates with a button from the top and aligns with the right
-
DIRTY DAVE about 4 years@mathheadinclouds doesn't work for me either. Did you ever get a work around?
-
Johannes Pertl almost 4 yearsStill no solution? It's 0 for me too