如何使用惯性效果平滑滚动Recyclerview?

How to scroll Recyclerview smoothly with inertia effect?

我在我的应用程序中使用 Recyclerview,我想为我的滚动提供惯性类型的效果,这样它就不会突然停在列表的顶部和底部,我该如何实现。 提前致谢。

您应该实现一个 class,它将滚动您的回收站视图。

注意:此 class 必须在 UI 线程中工作。

类似的东西:

mTimer = new Timer();
mMyTimerTask = new MyTimerTask();
// delay 1000 ms repeat in 1000ms
mTimer.schedule(mMyTimerTask, 1000, 1000);

RecyclerView recyclerView;
float currentScrollY = 0;

class MyTimerTask extends TimerTask {

        @Override
        public void run() {

        currentScrollY += 5;
        runOnUiThread(new Runnable() {

        @Override
        public void run() {
            recyclerView.scrollTo(0, currentScrollY);
        }
        });
    }
}

需要自己实现的惰性机制