Android Utililty Methods View Position Get

List of utility methods to do View Position Get


The list of methods to do View Position Get are organized into topic(s).


intgetPositionForView(final AdapterView adapterView, final View view)
Get the position within the adapter's dataset for the view, where view is an adapter item or a descendant of an adapter item.
int position = adapterView.getPositionForView(view);
if (adapterView instanceof ListView) {
    position -= ((ListView) adapterView).getHeaderViewsCount();
return position;
intgetRelativeTop(View myView)
get Relative Top
return getTop(myView) - myView.getTop();
intgetTop(View myView)
get Top
if (myView.getParent() == myView.getRootView())
    return myView.getTop();
    return myView.getTop() + getTop((View) myView.getParent());