Raghu Rami Reddy Raghu Rami Reddy - 1 year ago 60
Android Question

How can i get center x,y of my view in android?

I am attaching an imageview up on my frame layout. Here i want to get my imageview center co-ordinates. i will use that same co-ordinates to set my imageview in next layout. Please suggest me how to get the center co-ordinates of my imageview.

Thanks in advance

Answer Source

centre of the imageView will be

 centreX=imageView.getX() + imageView.getWidth()  / 2;
 centreY=imageView.getY() + imageView.getHeight() / 2;

but make sure you call it after the imageView created

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download