I want to get X and Y Point of View(ImageButton).
When I try to find X and Y on Click event with below code I get proper X and Y coordinate for View.
Get the values on onWindowFocusChanged()
.
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
ImageButton imagebutton = (ImageButton) findViewById(R.id.imagebutton);
int[] posXY = new int[2];
imagebutton.getLocationInWindow(posXY);
int x = posXY[0];
int y = posXY[1];
Log.d("X and Y Point", x + " " + y);
}