滚动条上的路径状标记

Path-like mark at scrollbar

我想为 android 实施 Path-like 时间标记。我找到了一些关于如何在 ListView 上实现它的指南,但我需要为其中包含不同大小项目的 RecyclerView 执行此操作。 我该怎么做?

我们使用了非常简单和愚蠢的方法来实现时间路径类标记的平滑动画。我们忽略了滚动条的真实位置,因为它很难获得并且它往往会根据内容大小大幅改变它的大小和位置。 在 RecyclerView 的 OnScrolled 方法中,我们根据 dy - 已滚动的像素数重新计算并重置视图边距。这是现在的代码:

            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
                if (dy == 0) return;
                if (dy < 0) {
                    if ((botMarg - dy) >= displayHeight - topOffset) {
                        botMarg = displayHeight - topOffset;
                    } else {
                        botMarg -= dy;
                    }
                } else {
                    if (botMarg - dy <= botOffset) {
                        botMarg = botOffset;
                    } else {
                        botMarg -= dy;
                    }
                }

为了获得当前视图,我们使用方法 recyclerView.findChildViewUnder() 和我们在 OnScrolled 中获得的位置。