Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to customize the fast scroll preview letter

I need to customize the fast scroll letter preview (the big M in the screenshot) with a custom background asset, but I can't find any documentation about it. Can you help me out?

enter image description here

like image 388
Santacrab Avatar asked Feb 10 '23 01:02

Santacrab


1 Answers

Thanks to @MAB and looking at the Lollipop source code, I managed to obtain 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 the c_fastscroller_thumb.xml is:

<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 application 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>
like image 72
Santacrab Avatar answered Feb 15 '23 10:02

Santacrab