1.方法一:
private void initScrollBar() {
try {
Field f = AbsListView.class.getDeclaredField("mFastScroller");
f.setAccessible(true);
Object o = f.get(mListView);
f = f.getType().getDeclaredField("mThumbDrawable");
f.setAccessible(true);
Drawable drawable = (Drawable) f.get(o);
drawable = getResources().getDrawable(R.drawable.music_slider);
f.set(o, drawable);
} catch (Exception e) {
e.printStackTrace();
}}</pre>
方法二:
在style.xml中定义主题
<style name="audiotheme" parent="android:Theme"> <item name="android:fastScrollTrackDrawable">@drawable/music_scroll_slider_background</item> <item name="android:fastScrollThumbDrawable">@drawable/music_slider</item> </style>
在AndroidManifest.xml中应用
<application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/audiotheme" >