how to change color of the actual scroll in ScrollView android?

后端 未结 4 1715
花落未央
花落未央 2020-12-24 04:58

I\'m wondering if it\'s possible to change the color of the ScrollView.

I\'m not referring to the background color or the edges.
I attached a print screen of th

相关标签:
4条回答
  • 2020-12-24 05:48

    Try this beautiful custom scrollview

    Add following tags in your scrollview

        android:fadeScrollbars="false"
        android:scrollbarStyle="insideInset"
        android:scrollbarThumbVertical="@drawable/scrollview_thumb"
        android:scrollbarTrackVertical="@drawable/vertical_scrollview_track"
    

    Create following drawable in your drawable folder

    scrollview_thumb.xml

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android">
    
    <solid android:color="@color/common_google_signin_btn_text_light_focused" />
    <corners android:radius="15dp" />
    
    </shape>
    

    vertical_scrollview_traack.xml

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android">
    
    <solid android:color="#E2E0EB" />
    <stroke
        android:width="1dp"
        android:color="#b3a9a9" />
    <size android:width="15dp" />
    <corners android:radius="15dp" />
    </shape>
    

    Output

    0 讨论(0)
  • 2020-12-24 05:49

    Taken from this question:

    You can set Listview property as or put the following attribute to your scrollview:

    android:scrollbarThumbVertical="@drawable/custom_scroll_style"
    

    Here custom_scroll_style is a xml file under the drawable folder. Lets create the custom_scroll_style.xml.

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android" >
    
    <gradient
    android:angle="45"
    android:endColor="#FF3401"
    android:centerColor="#ff5c33"
    android:startColor="#FF3401" />
    
    <corners android:radius="8dp" />
    
    </shape>
    
    0 讨论(0)
  • 2020-12-24 05:52

    Create a scroll bar in drawable(scrollbar.xml) using this

    <shape android:shape="rectangle"
        xmlns:android="http://schemas.android.com/apk/res/android">
        <gradient
             android:angle="45"
             android:centerColor="#65FF8215"
             android:endColor="#87FD2125"
             android:startColor="#65FF8215" />
        <corners android:radius="20dp" />
    </shape>
    

    and add this scroll bar like android:scrollbarThumbVertical="@drawable/scrollbar" to your ListView

    OR

    put the following attribute to your layout

    android:scrollbarThumbVertical="@android:color/white"
    

    OR

    create a image and put it in drawable. then add the following property to your layout

    android:scrollbarThumbVertical="@drawable/scroll_bar_vertical"
    
    0 讨论(0)
  • 2020-12-24 05:54

    put the following attribute to your layout

    android:scrollbarThumbVertical="@android:color/white"
    

    or create a image and put it in drawable. then add the following property to your layout

    android:scrollbarThumbVertical="@drawable/scroll_bar_vertical"
    
    0 讨论(0)
提交回复
热议问题