首页 > 解决方案 > 当 RecyclerView 滚动到特定点时(从底部开始并在屏幕中间完成其进度)时为 ProgreessBar 设置动画

问题描述

我在嵌套的 recyclerView 中有一个水平进度条。情况是我想在行列式进度条在底部上方 5 dp 时开始动画,并在到达屏幕中间时完成进度。想象一下你有一段时间滚动 recyclerView。一旦它在滚动 recyclerVeiw 时从底部出现,它就会开始增加进度,并在到达屏幕中间时完成进度。我附上了圆形进度条的演示视频,应该如何完成。任何建议将不胜感激。样品链接

我也试过这个和其他一些样品

    int[] location = new int[2];
    holder.progressbar_text.getLocationOnScreen(location);
    int menuViewX = location[0];
    int menuViewY = location[1];

我试图计算进度条的位置。如您所见,我正在垂直获取进度条的位置,即 menuViewY。这是我尝试过的解决方案link1link2 在上述两个问题中,我尝试了所有建议的解决方案。

    Log.i("bound", "Absolute Position" + menuViewY);

   // Progresbar animations
   holder.progressbar_text.enableAnimation();
   holder.progressbar_text.setScrollBarFadeDuration(9000);
   holder.progressbar_text.setAnimationSpeedScale(5);
   holder.progressbar_text.setProgress(40);
   holder.progressbar_text.setSecondaryProgress(70);

标签: javaandroidanimationandroid-recyclerviewandroid-progressbar

解决方案


推荐阅读