androidlistviewfastscroll

android listview fast scroll customization issue


here is my listview

<ListView android:layout_width="match_parent"
            android:layout_height="match_parent" android:id="@+id/ListView"
            android:fastScrollEnabled="true" android:divider="@null"
            style="@drawable/listviewfastscrollstyle"
            ></ListView>

This is listviewfastscrollstyle style file

<style> 
<item name="android:fastScrollTrackDrawable">@drawable/listselector</item> 
<item name="android:fastScrollThumbDrawable">@drawable/listselector</item> 
</style>

This is listselector file

<selector xmlns:android="http://schemas.android.com/apk/res/android">
 <item android:state_pressed="true" android:drawable="@drawable/channelarrows_down" /> 
 <item android:drawable="@drawable/minimize" /> 
 </selector>

But still the list view fast scroll bar is not getting customized.


Solution

  • The style you created isn't correct. You need to give it a name. I'm not sure what happened to your last post about this. Do the following:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
    
    <style name="listviewfastscrollstyle" parent="android:Theme">
        <item name="android:fastScrollTrackDrawable">@drawable/listselector</item>
        <item name="android:fastScrollThumbDrawable">@drawable/listselector</item>
    </style>
    
    </resources>
    

    In your Manifest set the style like this:

    <application 
        android:icon="@drawable/icon" 
        android:label="@string/app_name" 
        android:theme="@style/CustomTheme">
    

    As requested, this is the ListView I was testing on:

    <ExpandableListView
        android:id="@android:id/list"
        android:layout_width="match_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:drawSelectorOnTop="false"
        android:fastScrollAlwaysVisible="true"
        android:fastScrollEnabled="true"
        android:indicatorLeft="8dip"
        android:indicatorRight="52dip"
        android:paddingRight="32dip" />