控件在屏幕上的据对坐标

控件在屏幕上的绝对坐标获取方法:以屏幕左上角为坐标原点
int[] location = new int[2];

view.getLocationInWindow(location );

 
 
 
getLocationOnScreen的源码:
 public void getLocationOnScreen(int[] location) {
        getLocationInWindow(location);
 
        final AttachInfo info = mAttachInfo;
        if (info != null) {
            location[0] += info.mWindowLeft;
            location[1] += info.mWindowTop;
        }
    }  





原文地址:https://www.cnblogs.com/flyme2012/p/3949199.html