Example usage for android.widget ScrollView getHitRect

List of usage examples for android.widget ScrollView getHitRect

Introduction

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

Prototype

public void getHitRect(Rect outRect) 

Source Link

Document

Hit rectangle in parent's coordinates

Usage

From source file:com.androzic.PreferencesHelpDialog.java

public static void scrollToView(final ScrollView scrollView, final View view) {
    view.requestFocus();/*w ww  .j  av  a  2s.co  m*/

    final Rect scrollBounds = new Rect();
    scrollView.getHitRect(new Rect());
    if (!view.getLocalVisibleRect(scrollBounds)) {
        new Handler().post(new Runnable() {
            @Override
            public void run() {
                scrollView.smoothScrollTo(0, view.getBottom());
            }
        });
    }
}