Reputation: 1653
How to determine the coordinates (position ) of a view in android programmatically? I have a button placed in my xml file .How do i determine the coordinates of that button in java code?
Upvotes: 0
Views: 1708
Reputation: 56925
Here is the solution . Please check the link for find out the screen location of the View.
Upvotes: 1
Reputation: 1952
Try to see the methods getLocationInWindow and getLocationOnScreen.
http://developer.android.com/reference/android/view/View.html#getLocationInWindow(int[])
Upvotes: 0
Reputation: 974
get the view reference in java code.
Integer [] location = new Integer[];
view.getLocationOnScreen(location);
Now the integer array contains the co-ordinates of your view on screen.
Upvotes: 0