Holo fast scroll look on old devices
Asked Answered
U

2

8

About my app

I have an app that has the holo look.

For pre-Honeycomb devices, I just backported some elements of the Holo theme.

Working with themes, styles and attrs is ok for CheckBox, RadioButton ...

What I'm trying to do

I use a ListView to displays a lot of item. I want to enable fast scroll on my ListView and I want it to have the holo look.

My problem

I have some difficulties integrating the fast scroll Drawable it into my app theme.

What I've tried so far

  1. Looking for libraries that does this. HoloEverywhere was promising but doesn't handle that.

  2. Tried to do it myself:

I just added those drawables:

enter image description here enter image description here

Then also added this drawable:

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

Added this in my attrs.xml:

<attr name="fastScrollThumbDrawable" format="reference" />

I added this in my themes.xml:

<style name="MyTheme">
    <item name="fastScrollThumbDrawable">@drawable/fastscroll_thumb_holo</item>
</style>

This theme is properly set to my app in the Manifest.xml:

android:theme="@style/MyTheme"

Keep in mind that android:fastScrollThumbDrawable doesn't exist pre-honeycomb.


I hope you can help me solve this. :)

Update :

Looks like fast scroll support has been added to HoloEverywhere a few hours ago:

https://github.com/ChristopheVersieux/HoloEverywhere/commit/34561e48339bf6a3e0307d2d35fc4c5ac8409310

I will check that out. :)

Unroof answered 26/12, 2012 at 14:55 Comment(2)
have the HoloEverywhere solved your problem?Pembroke
I didn't try to integrate HoloEverywhere in my app but if the owner accepted the pull request it is certainly that it works. I looked how they did it and it looks like it's pretty heavy. Too much for me to integrate it in my app.Babiche
T
1

I'm using the android:fastScrollThumbDrawable but I not know why it isn't working, so searching on web i found here a hard code solution, I not know if it works on old API like you need, but in my case was solved the problem. Note I'm using API 18 like target and a device with API 17 to test.

the code:

try {
    Field f = AbsListView.class.getDeclaredField("mFastScroller");
    f.setAccessible(true);
    Object o = f.get(<<your listView here>>);
    f = f.getType().getDeclaredField("mThumbDrawable");
    f.setAccessible(true);
    Drawable drawable = (Drawable) f.get(o);
    drawable = getResources().getDrawable(R.drawable.<<your thumb drawable here can be a selector>>);
    f.set(o, drawable);
} catch (Exception e) {
    e.printStackTrace();
}
Thinkable answered 21/8, 2013 at 7:53 Comment(0)
A
0

Change this:

<style name="MyTheme">
    <item name="fastScrollThumbDrawable">@drawable/fastscroll_thumb_holo</item>
</style>

to something like this, it seemes that you forgot an antribute there:

<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="listviewfastscrollstyle" parent="android:Theme">
    <item name="android:fastScrollTrackDrawable">@drawable/fastscroll_thumb_holo</item>
    <item name="android:fastScrollThumbDrawable">@drawable/fastscroll_thumb_holo</item>
</style>

</resources>

Now it should work :)

Best Regards

safari

Arrearage answered 3/1, 2013 at 14:27 Comment(2)
Thank you for your answer. But this doesn't work. Keep in mind that the android:fastScrollTrackDrawable doesn't exist pre-honeycomb. Any other ideas ?Babiche
oh im sorry forgot about that, your right.... hmm ill think over something new..Arrearage

© 2022 - 2024 — McMap. All rights reserved.