要在RecyclerView上设置Android Scrollerbar,您需要执行以下步骤:

  1. 在XML布局文件中为RecyclerView添加一个android:scrollbars属性,如下所示:
<android.support.v7.widget.RecyclerView
    android:id="@+id/recyclerView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="vertical" />
  1. 在代码中,使用setVerticalScrollBarEnabled(true)方法启用垂直滚动条:
RecyclerView recyclerView = findViewById(R.id.recyclerView);
recyclerView.setVerticalScrollBarEnabled(true);
  1. 如果您想自定义滚动条的样式和颜色,您可以使用setScrollBarStyle方法和setScrollBarColor方法:
recyclerView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
recyclerView.setScrollBarColor(Color.BLUE);

这将设置滚动条的样式为SCROLLBARS_INSIDE_OVERLAY,并将滚动条的颜色设置为蓝色

安卓scrollerbar怎么设置在recyclerview上面

原文地址: https://www.cveoy.top/t/topic/hmH8 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录