recycler-fast-scroll
介绍:
recycler view的快速滚动和分节索引,支持横向。可以自定义样式和动画。
运行效果:
使用说明:
布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<com.futuremind.recyclerviewfastscroll.FastScroller
android:id="@+id/fastscroll"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"/>
</RelativeLayout>
Activity/Fragment:
recyclerView = (RecyclerView) findViewById(R.id.recyclerview);
fastScroller = (FastScroller) findViewById(R.id.fastscroll);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(adapter);
//has to be called AFTER RecyclerView.setAdapter()
fastScroller.setRecyclerView(recyclerView);
Horizontal orientation
你可以把这个library和horizontal LayoutManager一起使用。添加android:orientation="horizontal"属性就可以了:
<com.futuremind.recyclerviewfastscroll.FastScroller
android:id="@+id/fastscroll"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
样式
可以在xml中定义属性:
<com.futuremind.recyclerviewfastscroll.FastScroller
...
app:fastscroll__handleColor="#8f93d1"
app:fastscroll__bubbleColor="#5e64ce"
app:fastscroll__bubbleTextAppearance="@style/StyledScrollerTextAppearance"
/>
或者直接在代码中:
fastScroller.setBubbleColor(0xffff0000);
fastScroller.setHandleColor(0xffff0000);
fastScroller.setBubbleTextAppearance(R.style.StyledScrollerTextAppearance);
自定义View
你可以为handle和bubble设置自定义的布局和动画,使用:
myViewProvider = new MyScrollerViewProvider();
fastScroller.setViewProvider(myViewProvider);
更多信息,参考例子中的[CustomScrollerViewProvider](https://github.com/FutureMind/recycler-fast-scroll/blob/master/example/src/main/java/com/futuremind/recyclerviewfastscroll/example/CustomScrollerViewProvider.java)。
下载
Gradle:
compile 'com.futuremind.recyclerfastscroll:fastscroll:0.2.3'
已下载
0