Example usage for android.widget ScrollView offsetDescendantRectToMyCoords

List of usage examples for android.widget ScrollView offsetDescendantRectToMyCoords

Introduction

In this page you can find the example usage for android.widget ScrollView offsetDescendantRectToMyCoords.

Prototype

public final void offsetDescendantRectToMyCoords(View descendant, Rect rect) 

Source Link

Document

Offset a rectangle that is in a descendant's coordinate space into our coordinate space.

Usage

From source file:au.org.ala.fielddata.mobile.CollectSurveyData.java

public void scrollTo(final Attribute attribute) {
    pager.post(new Runnable() {
        public void run() {

            Binder binder = (Binder) surveyViewModel.getAttributeListener(attribute);
            View boundView = binder.getView();
            ViewParent parent = boundView.getParent();
            while (parent != null && !(parent instanceof ScrollView)) {
                parent = parent.getParent();
            }//from   w  w  w . j  av a  2 s . com

            if (parent != null) {
                final ScrollView view = (ScrollView) parent;
                final Rect r = new Rect();

                view.offsetDescendantRectToMyCoords((View) boundView.getParent(), r);
                view.post(new Runnable() {
                    public void run() {
                        view.scrollTo(0, r.bottom);
                    }
                });

            }
        }
    });
}