Android examples for User Interface:View Property
get the relative coordinate between two View
//package com.java2s; import android.graphics.Point; import android.view.View; public class Main { /**//from www . j a v a 2 s . c o m * get the relative coordinate * * @param view * @param relativeView * @return the relative location */ public static Point getRelativeLocation(View view, View relativeView) { if (view != null && relativeView != null && view != relativeView) { int[] location = new int[2]; view.getLocationOnScreen(location); int[] location2 = new int[2]; relativeView.getLocationOnScreen(location2); return new Point(location[0] - location2[0], location[1] - location2[1]); } return new Point(0, 0); } }