【问题标题】:How to create material design like custom scrollbar with numbers and alphabets bubble in recyclerview如何在recyclerview中创建带有数字和字母气泡的自定义滚动条之类的材料设计
【发布时间】:2015-09-24 12:28:57
【问题描述】:

在许多新的 android 应用程序及其最新更新中,这些应用程序(主要是材料设计)具有带有字母和数字的自定义滚动条,而用拇指滚动滚动条时,字母或数字出现在拇指旁边。我已将屏幕截图附加到问题来自应用程序“联系人”的滚动条。

截图:

那么,如何在我的使用 recyclerview 的应用程序中修改滚动条,以创建带有字母和数字气泡的滚动条,或者是否为此引入了任何新的 API 或库?

【问题讨论】:

  • 好问题 :D :P

标签: android material-design


【解决方案1】:

List View Variants 库似乎非常适合您的需求,请尝试一下。

查看下面的演示。

【讨论】:

    【解决方案2】:

    对于仍在寻找答案的任何人。我找到了许多提供此功能的库:

    1. https://github.com/krimin-killr21/MaterialScrollBar
    2. https://github.com/plusCubed/recycler-fast-scroll
    3. https://github.com/danoz73/RecyclerViewFastScroller
    4. https://github.com/timusus/RecyclerView-FastScroll

    以上所有都提供 FastScroll 机制(您正在寻找的) - 尽管有些看起来比其他更好。

    我发现MaterialScrollBar 最容易设置和使用,而且它拥有最好的化妆品(遵守材料设计指南并且看起来就像联系人应用程序)。

    这个库也在积极维护和开发,问题和 PR 正在关闭等。

    希望这可以帮助某人,因为我自己花了很多时间寻找这个。

    【讨论】:

      【解决方案3】:

      我现在用这个新的 - https://github.com/L4Digital/FastScroll

      下面是我以前的。

      我在 Android Studio

      中使用过 FutureMind 的 fastscroller

      https://github.com/FutureMind/recycler-fast-scroll

      用法

      1) 通过添加编译所需的依赖项

      编译'com.futuremind.recyclerfastscroll:fastscroll:0.2.4'

      2) 编辑布局文件以添加 FastScroller

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

      3) 在 Activity/Fragment 中,将 fastScroller 与您的回收站视图关联

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

      4) 在您的 RecyclerView.Adapter 中实现 SectionTitleProvider 以在 Bubble 上显示内容

          public class MyAdapter ... implements SectionTitleProvider{
      
              ...
      
              @Override
              public String getSectionTitle(int position) {
                  //this String will be shown in a bubble for specified position
                  return getItem(position).substring(0, 1);
              }
      
          }
      

      【讨论】:

        【解决方案4】:

        这个库运行良好且易于使用 - Material Scroll Bar

        它还支持自定义字体。

        【讨论】:

          猜你喜欢
          • 2019-10-13
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2015-12-09
          • 1970-01-01
          • 2017-01-12
          • 1970-01-01
          相关资源
          最近更新 更多