Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to disable Android ListView animation?

When we drag a ListView to the end or to the top, we can always drag it a little further and it will show a blank background, then when we release it the ListView will bounce back. It's a default animation effect of ListView.

I would like to disable this animation effect.

like image 675
Xi 张熹 Avatar asked Apr 25 '11 13:04

Xi 张熹


2 Answers

This may work. Create a new class that contains the following.

import android.view.View;

public class OverScrollDisabler
{
    public static void disableOverScroll(View view)
    {
        view.setOverScrollMode(View.OVER_SCROLL_NEVER);
    }
}

Then within your code,

if(Build.VERSION.SDK_INT >= 9)
{
    OverScrollDisabler.disableOverScroll(myView);
}

More details here: http://jasonfry.co.uk/?id=30

like image 171
Haphazard Avatar answered Sep 20 '22 05:09

Haphazard


In your xml add the attribute

android:overScrollMode="never"
like image 28
slott Avatar answered Sep 24 '22 05:09

slott