RecyclerView的速度控制

时间:2018-07-06 13:46:19

标签: android android-recyclerview android-animation

我有3个回收站视图,当一个滚动条同时滚动两个滚动条时,我使用的是OnScrollListener

    @Override
    public void onScrolled(RecyclerView recyclerView, final int dx, final int dy) {
             super.onScrolled(recyclerView, dx, dy);
                  recyclerView2.removeOnScrollListener(this);
                  recyclerView3.removeOnScrollListener(this);
                  recyclerView2.scrollBy(dx , 0);
                  recyclerView3.scrollBy(dx , 0);
                  recyclerView2.addOnScrollListener(this);
                  recyclerView3.addOnScrollListener(this);
     }

这工作正常,但我希望滚动时recyclerView2和recyclerView3减速

我尝试使用fling()

recyclerView1.setOnFlingListener(new RecyclerView.OnFlingListener() {

         @Override
         public boolean onFling(int velocityX, int velocityY) {
              recyclerView2.fling(40* (int) Math.signum((double)velocityX), velocityY);
              recyclerView3.fling(60* (int) Math.signum((double)velocityX), velocityY);
              return true;     
         }
});

这将使3 recycler减速,而不是仅使recyclerView2和recyclerView3减速

0 个答案:

没有答案