Android ListView - change default LinearInterpolator used in programmatic smooth scrolling

602 views Asked by At

I am using ListView to implement a simple slot machine. I want to use it's view recycling features. Everything is fine except that I can't find a way to change the default animation interpolator used.

This is the line of code that is smooth scrolling to a position:

getListView().smoothScrollToPositionFromTop(position,offset,duration);

It works fine except that it is animating to that position in a linear fashion, using LinearInterpolator by default. Is there a way/workaround to provide custom interpolator like AccelerateDecelerateInterpolator instead of LinearInterpolator ?

Thanks in advance.

I found this online, but I don't know how to override, it's final.

https://github.com/android/platform_frameworks_base/blob/master/core/java/android/widget/AbsListView.java

public abstract class AbsListView extends AdapterView<ListAdapter> implements TextWatcher,
    ViewTreeObserver.OnGlobalLayoutListener, Filter.FilterListener,
    ViewTreeObserver.OnTouchModeChangeListener,
    RemoteViewsAdapter.RemoteAdapterConnectionCallback {

/**
 * Used for smooth scrolling at a consistent rate
 */
static final Interpolator sLinearInterpolator = new LinearInterpolator();
1

There are 1 answers

0
Denys Kravchenko On

Try to use RecyclerView, it can use custom interpolators.