get View Relative Top - Android User Interface

Android examples for User Interface:View Property

Description

get View Relative Top

Demo Code


//package com.java2s;

import android.view.View;

public class Main {
    private static int getRelativeTop(View myView) {
        if (myView.getParent() == myView.getRootView())
            return myView.getTop();
        else/*from  w  w  w .j  a  va2 s . c  o  m*/
            return myView.getTop()
                    + getRelativeTop((View) myView.getParent());
    }
}

Related Tutorials