private int[] Position = new int[2];
需要在onWindowFocusChanged中获取,既画面已经被绘制好了才可以获取坐标
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
view.getLocationInWindow(Position);
}
然后就获取到了x,y的坐标,具体含义如图中所画