Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get position of imageview on layout android

Please help me i want to get position of imageview on a layout.

enter image description here

like image 649
Programmer Avatar asked Feb 03 '12 08:02

Programmer


4 Answers

x = imageViewObject.getLeft();
y = imageViewObject.getTop();

Hope, it help you!

like image 68
ihrupin Avatar answered Nov 15 '22 17:11

ihrupin


You can use this with getLocationOnScreen(int [])

like image 33
IMCoder Avatar answered Nov 15 '22 19:11

IMCoder


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 [] )

like image 28
Andreas Avatar answered Nov 15 '22 17:11

Andreas


Position meaning x and y and height and width?

This layout is a view, that view has these properties.

like image 1
JoxTraex Avatar answered Nov 15 '22 18:11

JoxTraex