RecyclerView 中的滚动条颜色 [英] Scrollbar color in RecyclerView

查看:70
本文介绍了RecyclerView 中的滚动条颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 recyclerView 中更改滚动条的颜色?

How can I change the color of my scrollbar in a recyclerView?

我有滚动条,但我想改变它的颜色.我的recyclerView是这样的:

I have the scrollbar but I want to change its color. My recyclerView is like this:

 <android.support.v7.widget.RecyclerView
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:id="@+id/recyclerView"
   android:layout_below="@id/my_toolbar"
   android:layout_above="@+id/progressBar"
   android:scrollbars="vertical"
   />

推荐答案

您可以通过在 Recyclerview 中包含以下代码行来做到这一点

You can do this by including following line of code in your Recyclerview

android:scrollbarThumbVertical="@drawable/yoursdrawablefile

在我的例子中的可绘制文件是:

The drawable file in my case is:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient android:startColor="#000" android:endColor="#000"
        android:angle="45"/>
    <corners android:radius="6dp" />
</shape>

这篇关于RecyclerView 中的滚动条颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆