首先要说一点的是,获取的坐标是控件左上角的坐标点。
注意:下面的view是你需要获取坐标的控件。
int[] outLocation=new int[2]; view.getLocationOnScreen(outLocation); int x=outLocation[0]; int y=outLocation[1];
首先要说一点的是,获取的坐标是控件左上角的坐标点。
注意:下面的view是你需要获取坐标的控件。
int[] outLocation=new int[2]; view.getLocationOnScreen(outLocation); int x=outLocation[0]; int y=outLocation[1];