RecyclerViewFastScroller

介绍:

RecyclerViewFastScroller是然RecyclerView显示快速滚动条条的控件, 只要将它RecyclerView关联起来,就能显示出类似于ListView 快速滚动模式中的滚动条。

运行效果:

使用说明:

VerticalRecyclerViewFastScroller和RecyclerView一起放入一个布局文件中,本例是放入Relativelayout中:

...
  <android.support.v7.widget.RecyclerView
      android:id="@+id/recyclerView"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      />
  <your.package.name.scroller.vertical.VerticalRecyclerViewFastScroller
      android:id="@+id/fast_scroller"
      android:layout_width="@dimen/however_wide_you_want_this"
      android:layout_height="match_parent"
      android:layout_alignParentRight="true"
      />...

在Activity或者Fragment中将VerticalRecyclerViewFastScroller和RecyclerView关联:

...
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      View rootView = inflater.inflate(R.layout.recycler_view_frag, container, false);
      ...
      // Grab your RecyclerView and the RecyclerViewFastScroller from the layout
      RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerView);
      VerticalRecyclerViewFastScroller fastScroller = (VerticalRecyclerViewFastScroller) rootView.findViewById(R.id.fast_scroller);
      // Connect the recycler to the scroller (to let the scroller scroll the list)
      fastScroller.setRecyclerView(recyclerView);
      // Connect the scroller to the recycler (to let the recycler scroll the scroller's handle)
      recyclerView.setOnScrollListener(fastScroller.getOnScrollListener());
      ...
      return rootView;
  }
...

可配置的选项:

  <attr name="barColor" format="color|reference" />
  <attr name="barBackground" format="reference" />
  <attr name="handleColor" format="color|reference" />
  <attr name="handleBackground" format="reference" />
已下载
0