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

前端 未结 3 398
不知归路
不知归路 2020-12-05 17:25

Currently this is my scrollbar.xml file:




        
相关标签:
3条回答
  • 2020-12-05 18:01

    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" >
    
    0 讨论(0)
  • 2020-12-05 18:10

    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>
    
    0 讨论(0)
  • 2020-12-05 18:12

    add the following property to your layout

    android:scrollbarSize="50dip"
    
    0 讨论(0)
提交回复
热议问题