Change ListView ScrollBar / FastScroll List Color?

My app has an orange theme, but ScrollBar / FastScroll looks green. I tried to search a lot, but cannot find a way to change this. He just stays the way he is.

I found the property "android: fastScrollTextColor", but this changes the color B inside the bubble. And I cannot find any property to change the color of this bubble or ScrollBar next to it.

Snapshot

In case that matters, I use the custom PinnedHeaderListView, which I got from here to mimic the sticky headers in the contacts with the candy app.

+4
source share
3 answers

The color of the scroll palette is set to the android:colorAccent in the application theme. Are you sure that it is installed and correct, right?

Note that if you use AppCompat, you will have to exclude the android: prefix from the attribute.

You can find more information on the available color attributes here .

+4
source

set This is in your listView attributes in the XML file.

 android:scrollbarSize="10dp" android:scrollbarThumbVertical="@drawable/custom_scroll_style" 

Here custom_scroll_style is an xml file in a folder with the ability to transfer. Let's create custom_scroll_style.xml

 <shape xmlns:android="http://schemas.android.com/apk/res/android" > <gradient android:angle="45" android:endColor="@color/endColor" //define what you want android:centerColor="@color/centercolor" android:startColor="@color/startColor" /> <corners android:radius="8dp" /> <size android:width="4dp"/> <padding android:left="0.5dp" android:right="0.5dp" /> </shape> 

Hope this helps!

+1
source

android:scrollbarThumbVertical will work fine. But if fastscroll is enabled in listView , you must define android:fastScrollThumbDrawable in AppTheme or any theme and use it for activity (in AndroidManifest ) that contains listview with fastscroll enabled.

The styles.xml part

 <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="colorAccent">@color/colorAccent</item> <item name="android:fastScrollThumbDrawable">@drawable/fast_scrollbar_vertical</item> </style> 

part of the manifest

  <activity android:name=".ListActivity" android:label="@string/title_activity_list" android:theme="@style/AppTheme" /> 

and the allowable scrollbar width should be gradient

 <shape xmlns:android="http://schemas.android.com/apk/res/android" > <gradient android:angle="45" android:endColor="@color/scroll_color" android:centerColor="@color/scroll_color" android:startColor="@color/scroll_color" /> <corners android:radius="8dp" /> <size android:width="8dp" android:height="100dp"/> <padding android:left="0.5dp" android:right="0.5dp" /> </shape> 
0
source

Source: https://habr.com/ru/post/1246133/


All Articles