Here you can find the source of getRelativeTop(View myView)
public static int getRelativeTop(View myView)
//package com.java2s; import android.view.View; public class Main { public static int getRelativeTop(View myView) { return getTop(myView) - myView.getTop(); }//from ww w. j a va 2 s .com public static int getTop(View myView) { if (myView.getParent() == myView.getRootView()) return myView.getTop(); else return myView.getTop() + getTop((View) myView.getParent()); } }