Example usage for android.widget AbsListView smoothScrollBy

List of usage examples for android.widget AbsListView smoothScrollBy

Introduction

In this page you can find the example usage for android.widget AbsListView smoothScrollBy.

Prototype

public void smoothScrollBy(int distance, int duration) 

Source Link

Document

Smoothly scroll by distance pixels over duration milliseconds.

Usage

From source file:com.czy.reecycleviewheader.ScrollableHelper.java

@SuppressLint("NewApi")
public void smoothScrollBy(int velocityY, int distance, int duration) {
    View scrollableView = getScrollableView();
    if (scrollableView instanceof AbsListView) {
        AbsListView absListView = (AbsListView) scrollableView;
        if (mSystemVersion >= 21) {
            absListView.fling(velocityY);
        } else {//from ww w  .  jav  a2s  . c  om
            absListView.smoothScrollBy(distance, duration);
        }
    } else if (scrollableView instanceof ScrollView) {
        ((ScrollView) scrollableView).fling(velocityY);
    } else if (scrollableView instanceof RecyclerView) {
        ((RecyclerView) scrollableView).fling(0, velocityY);
    } else if (scrollableView instanceof WebView) {
        ((WebView) scrollableView).flingScroll(0, velocityY);
    }

}