How to set up a quick scrolling letter
2 answers
Thanks to @MAB and studying the Lollipop source code, I managed to get exactly what I needed
My c_fastscroller_preview.xml :
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:topLeftRadius="44dp"
android:topRightRadius="44dp"
android:bottomLeftRadius="44dp" />
<padding
android:paddingLeft="22dp"
android:paddingRight="22dp" />
<solid android:color="@color/c_red_e60000" /></shape>
where c_fastscroller_thumb.xml :
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/c_fastscroll_thumb" />
<item
android:drawable="@drawable/c_fastscroll_thumb" /></selector>
And in my app styles.xml :
<!-- This belongs in a FastScroll style -->
<item name="android:fastScrollThumbDrawable">@drawable/c_fastscroller_thumb</item>
<item name="android:fastScrollPreviewBackgroundRight">@drawable/c_fastscroller_preview </item>
<item name="android:fastScrollOverlayPosition">aboveThumb</item>
<item name="android:fastScrollTextColor">@color/c_white</item>
+5
source to share
This can be done by creating your own style under res/values/styles.xml
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:fastScrollThumbDrawable">@drawable/fastscroll_thumb</item>
<item name="android:fastScrollOverlayPosition">atThumb</item>
<item name="android:fastScrollTextColor">@color/your_color</item>
<item name="android:fastScrollTrackDrawable">@drawable/fastscroll_thumb_pressed</item>
</style>
where fastScroll_thumb is a selector
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/fastscroll_thumb_pressed" android:state_pressed="true"/>
<item android:drawable="@drawable/fastscroll_thumb_default"/>
</selector>
and fastfastscroll_thumb_pressed / fastscroll_thumb_default are blueprints that you can customize as you like
PS: Don't forget to include the style of your activity in the manifest.
Correct me if I am wrong, but I think there are many questions discussing the same problem.
Good luck.
+1
source to share