Example usage for android.widget AbsListView fling

List of usage examples for android.widget AbsListView fling

Introduction

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

Prototype

public void fling(int velocityY) 

Source Link

Document

Initiate a fling with the given velocity.

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. j  a va 2 s  .  c o  m*/
            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);
    }

}