androidandroid-listviewandroid-scrollbarfastscroll

ThumbDrawable of FastScrollBar is not changing.


EDITED

My ListView is :

  <ListView
    android:id="@android:id/list"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:divider="#0d2e3a"
    android:dividerHeight="1dp"
    android:fastScrollEnabled="true"
    style="@style/myScrollBar" />

Then, in Values my style for fastscrollbar is :

<style name="myScrollBar" >
     <item name="android:fastScrollThumbDrawable">@drawable/fastscroll_thumb</item>
</style>

And, Then my fastscroll_thumb.xml is :

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true" android:drawable="@drawable/fast_track_drawable" />
<item android:drawable="@drawable/fast_drawable" />
</selector>

Where, fast_track_drawable and fast_drawable are two images.

But, my fastscrollbar is still not being customized. Can any one point out, where m i mistaken. i have seen some tutorials as well like android listview fast scroll customization issue, And How to show custom thumb when using fastScrollEnabled


Solution

  • First, remove style explicitly mentioned in ListView xml. Added the style in value where other styles were mentioned. Then designed the selector.

    <style name="Theme.Customactionbartheme" parent="@android:style/Theme.Holo.Light.DarkActionBar">
    <item name="android:actionBarStyle">@style/MyActionBarStyle</item>
    <item name="android:actionBarTabStyle">@style/MyActionBarTabStyle</item>
    <item name="android:popupMenuStyle">@style/PopupMenu.Customactionbartheme</item>
    <item name="android:actionDropDownStyle">@style/DropDownNav.Customactionbartheme</item>
    <item name="android:homeAsUpIndicator">@drawable/ic_navigation_drawer</item>
    <item name="android:fastScrollThumbDrawable">@drawable/fastscroll_thumb</item>  
    </style>
    

    And the Selector is:

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:state_pressed="true" android:drawable="@drawable/fast_track_drawable" />
    <item android:drawable="@drawable/fast_drawable_orange" />
    </selector>