Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Listview slow down scroll speed

Tags:

The scroll speed in the ListView is way too fast for my application. I need to slow it down by a lot.

I can't figure out how to do this. The only things I could find in the documentation are a "setFriction" function which is only supported in API Level 11, and a static "getScrollFriction" method which can't be overridden and has no corresponding setter.

What's the trick here - how do I control the scroll speed?

Thanks.

like image 474
Frank LaRosa Avatar asked Apr 08 '11 03:04

Frank LaRosa


2 Answers

Verified that this works really nicely for API >= 11:

listView.setFriction(ViewConfiguration.getScrollFriction() * FRICTION_SCALE_FACTOR) 

Note that scroll speed decreases as friction increases. To decrease scroll momentum by a suitable amount, I ended up using a friction scale factor of 10. YMMV.

like image 157
greg7gkb Avatar answered Sep 30 '22 02:09

greg7gkb


Yes, there's no easy way. Before API 11, friction was hardcoded inside Scroller, and there's no simple way to change a scrolling view's Scroller. Scroller itself is quite simple, but the mScroller member in AbsListView is private, so you can't just extend ListView.

like image 30
bigstones Avatar answered Sep 30 '22 01:09

bigstones