Android examples for User Interface:View Child
Return the position of childView relative to rootView .
//package com.java2s; import android.view.View; public class Main { public static void getRelativeDrawPosition(View rootView, View childView, int[] outPosition) { assert outPosition.length == 2; outPosition[0] = 0;//from w w w. j a v a 2 s . c om outPosition[1] = 0; while (childView != null && childView != rootView) { outPosition[0] += childView.getX(); outPosition[1] += childView.getY(); childView = (View) childView.getParent(); } } }