/**
* Get the boundary of a view in screen coordinates.
* 类似 Windows SDK 中的 GetWindowRect + ClientToScreen
* @param v
* @param r The result.
*/
private void getRectInScreen(View v, Rect r) {
final int w = v.getWidth();
final int h = v.getHeight();
r.left = v.getLeft();
r.top = v.getTop();
r.right = r.left + w;
r.bottom = r.top + h;
ViewParent p = v.getParent();
while(p instanceof View) {
v = (View)p;
p = v.getParent();
r.left += v.getLeft();
r.top += v.getTop();
r.right = r.left + w;
r.bottom = r.top + h;
}
* Get the boundary of a view in screen coordinates.
* 类似 Windows SDK 中的 GetWindowRect + ClientToScreen
* @param v
* @param r The result.
*/
private void getRectInScreen(View v, Rect r) {
final int w = v.getWidth();
final int h = v.getHeight();
r.left = v.getLeft();
r.top = v.getTop();
r.right = r.left + w;
r.bottom = r.top + h;
ViewParent p = v.getParent();
while(p instanceof View) {
v = (View)p;
p = v.getParent();
r.left += v.getLeft();
r.top += v.getTop();
r.right = r.left + w;
r.bottom = r.top + h;
}
}