MonkeyRunner: easy way to determine coordinates for MonkeyDevice touch command?

I found how to do it. Use the Pixel Perfect view within Eclipse to determine the x & y coordinates of the UI element. Here's a quick overview: 1) Eclipse must be running 2) Your Android device must be connected (either the real device via ADB, or the emulator) 3) Run the hierarchy viewer (in /tools) 4) Select "Inspect screenshot" The Pixel Perfect view will launch automatically. Just place the cross-hairs on the UI element. The x and y coordinates, along with the RGB values, are displayed below.

Here's the URL that got me started: http://developer.android.com/guide/developing/debugging/debugging-ui.html#pixelperfect


This post (monkeyrunner: interacting with views), may give you and idea of how to obtain the View's coordinates using AndroidViewClient.


Most of the Android versions you can enable pointer location in Settings->Developer Options. Once you enable it, it is easy to find out the (x,y) coordinates.