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.
Two options:
onResume.Using ViewTreeObserver.
final ViewTreeObserver vto = findViewById(R.id.YOUR_VIEW_ID).getViewTreeObserver();
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
vto.removeOnGlobalLayoutListener(this);
// Get X, Y of the ImageView here
}
});