Android examples for User Interface:ViewGroup
get ViewGroup Absolute Coordinates
//package com.java2s; import java.util.ArrayList; import android.graphics.Point; import android.view.View; import android.view.ViewGroup; public class Main { public static Point getAbsoluteCoordinates(ViewGroup v, ArrayList<Integer> ns) { Point point = new Point(); point.x = 0;/* w ww . ja v a2 s. co m*/ point.y = 0; ViewGroup parent = v; for (int i = 0; i < ns.size(); i++) { View child = parent.getChildAt(ns.get(i)); point.x += child.getLeft(); point.y += child.getTop(); try { parent = (ViewGroup) child; } catch (ClassCastException e) { } } return point; } }