如何创建自定义的一样滚动数字和字母的recylerview泡沫材料设计自定义、泡沫、字母、数字

2023-09-05 06:55:13 作者:我宣你你造吗

在许多新的Andr​​oid应用程序及其最新更新这些应用程序(主要是材料设计)有一个自定义的滚动字母和数字,滚动时用拇指滚动条,字母或数字显示旁边thumb.I附上截图的问题滚动条从应用程序的联系人。

In many new android applications and their latest update those applications(mostly material design) have a custom scrollbar with letters and numbers, while scrolling the scrollbar with thumb, alphabets or numbers appear beside thumb.I have attached screenshot to the question of the scrollbar from the application 'Contacts'.

截图:

Screenshot:

那么,如何修改我的应用程序中的滚动条是用recyclerview,创建滚动条这样滚动条的字母和数字的泡沫,或有任何新的API或库介绍是什么?

So, How to modify a scrollbar in my application which is using recyclerview, to create scrollbar like that scrollbar with the alphabet and number bubble or is there any new API or library introduced for that?

推荐答案

我可以从你的问题明白了,你要实现的快速滚动在Android的功能。

As I can understand from your question, you want to implement the "Fast Scroll" feature in Android.

此功能可让您快速通过一个大的列表中滚动。您可以使用这第三方库,轻松实现了。

This feature lets you quickly scroll through a large list. You can easily implement it using this third-party library.

它非常简单,重量轻和高度定制太。不要看上面的截图小看它。你可以很容易使它看起来像您所提供的屏幕截图。我用它的某个时候回到我的应用程序之一,并获得了优异的成绩。

Its very simple, light-weight and is highly customization too. Don't underestimate it by looking at the screenshot above. You can easily make it look like the screenshot you provided. I used it sometime back in one of my apps and got excellent results.

用法

使用这个库也很简单。你只需要包括它的 QuickScroll 的布局和实施的BaseAdapter的滚动接口。给这个插件的材质的外观和感觉是非常简单的。

Using this library is also simple. You just need to include its QuickScroll layout and implement the Scrollable interface on your BaseAdapter. Giving this widget the Material look-and-feel is really simple.

由于用户的需求,为所有那些谁想要知道如何使用快速滚动在RecyclerView功能,这是给你的一切。您可以使用这库。

Due to user demand, for all those who want to know how to use "Fast Scroll" feature in RecyclerView, here it is for you all. You can use this library.

它可以给你的结果非常接近(如果不是精确的)所提供的屏幕截图。你只需要使用 RecyclerViewFastScroller 部件的布局。

It can give you results which is very close (if not exact) to the screenshot provided. You just have to use RecyclerViewFastScroller widget in your layout.

用法

第1步

添加这种依赖

compile 'xyz.danoz:recyclerviewfastscroller:0.1.3'

第2步

现在在你的XML,你需要把这个小工具

Now in your XML you need to put this widget

<android.support.v7.widget.RecyclerView
      android:id="@+id/recyclerView"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      />

  <xyz.danoz.recyclerviewfastscroller.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"
      />

,然后在code,

and then in your code,

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;
  }

有很多的附加属性来定制你想要的方式。您可以创建完全一样的您提供的屏幕截图的外观和感觉。

There are lots of additional attributes to customize it the way you want to. You can create exactly the same look-and-feel of the screenshot you provided.

使用库可以节省大量的时间,但在情况下,如果你想从头开始构建这个功能,的此处对你是一个非常有用的帖子。

Using a library can save a lot of time, but in case if you want to build this feature from scratch, here is a very useful post for you.

希望它帮助。