How can I change the width/thickness of a scrollbar?

陌路散爱 提交于 2019-11-27 21:52:19

add the following property to your layout

android:scrollbarSize="50dip"

see the android:scrollbarSize="" attribute of ScrollView.

<ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_below="@+id/btnBack"
    android:scrollbarSize="4dp"
    android:scrollbarThumbVertical="@drawable/scrollbar" >

For making very easy and using many times, same type of scrollbar in list view, use as a style and color in style.xml and color.xml in values folder.

i.e. in Android Studio :

Project_Name/app/main/res/values

and the code in

style.xml

 <resources>    
   <style name="mScrollBar">
     <item name="android:scrollbarSize">1dp</item>
     <item name="android:scrollbarThumbVertical">@color/base_color</item>
   </style>
 </resources>

in color.xml

 <?xml version="1.0" encoding="utf-8"?>
 <resources>
     <color name="Salmon">#FA8072</color>
 </resources>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!