Retrieve the X & Y coordinates of a button in android?
问题 I've been working on Android for a while and would like to know if it is possible to retrieve the position of a button in android. My target is to get the X & Y coordinates and print them on the LOGCAT. Some example to show me how would be appreciated. Thanks 回答1: Sure, you can get these, make sure the views are drawn atleast once before you try to get the positions. You could try to get the positions in onResume() and try these functions view.getLocationInWindow() or view.getLocationOnScreen