the method you use expects integer values as R.string.whatever references. Insert the return value of getTop () into a String.
Toast.makeText(MainActivity.this, String.valueOf(button1.getTop()), Toast.LENGTH_LONG).show();
To get x / y buttons (starting with API 11):
Toast.makeText(MainActivity.this, (int)button1.getX() + ":" + (int)button1.getY(), Toast.LENGTH_LONG).show();
Doc :
The visual x position of this view in pixels.
For APIs below 11, you are on the right track: getTop() is the equivalent of getY() , but without possible animation / translation. getLeft() is an equivalent of getX() with the same restriction.
source share