Is there a way to turn off Android ListView animation?

When we drag the ListView to the end or up, we can always drag it a little further, and it will display an empty background, and then when we release it, the ListView will go back. This is the default animation effect of a ListView .

I would like to turn off this animation effect.

+7
android listview
source share
4 answers

It might work. Create a new class containing the following.

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

Then in your code

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

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

+11
source share

In xml add attribute

 android:overScrollMode="never" 
+8
source share

For older versions of api <9, consider:

 @Override public boolean dispatchTouchEvent(MotionEvent ev) { int action = ev.getAction(); if (action == MotionEvent.ACTION_MOVE) { ev.setAction(MotionEvent.ACTION_CANCEL); super.dispatchTouchEvent(ev); return true; } return super.dispatchTouchEvent(ev); } 
+1
source share

All Articles