Android View Position Get getRelativeTop(View myView)

Here you can find the source of getRelativeTop(View myView)

Description

get Relative Top

Declaration

public static int getRelativeTop(View myView) 

Method Source Code

//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());
    }
}

Related

  1. getPositionForView(final AdapterView adapterView, final View view)
  2. getTop(View myView)