0

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?

Joyson
  • 1,643
  • 5
  • 28
  • 48
  • See this link: http://stackoverflow.com/questions/3228248/android-button-position-programmatically –  Sep 17 '12 at 10:20

3 Answers3

1

Here is the solution . Please check the link for find out the screen location of the View.

Chirag
  • 56,621
  • 29
  • 151
  • 198
0

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.

knvarma
  • 974
  • 5
  • 6
0

Try to see the methods getLocationInWindow and getLocationOnScreen.

http://developer.android.com/reference/android/view/View.html#getLocationInWindow(int[])

Oibaf it
  • 1,842
  • 16
  • 9