Java tutorial
//package com.java2s; //License from project: Open Source License import android.graphics.Rect; import android.view.View; import android.view.ViewGroup; public class Main { /** * Returns the descendant's frame relative to the parent. Applies conversion if views are * between the descendant and the parent. * * @param parent the returned frame will be relative to this view * @param descendant any view underneath the parent view. * @return the descendant's frame in parent view coordinates */ public static Rect convertedRectForDescendant(ViewGroup parent, View descendant) { Rect result = new Rect(0, 0, descendant.getWidth(), descendant.getHeight()); // alternately: descendant.getDrawingRect() ? parent.offsetDescendantRectToMyCoords(descendant, result); return result; } }