Posted by & filed under Programming.

Let’s say you want to make a static list view, perhaps because all the items in the list fit on the screen (no matter how small). Android doesn’t offer an easy way to accomplish this with something like myListView.setEnableScrolling(false); There is a StackOverflow question that provides an easy way to do it using a custom view, as well as a few other options that work by preventing the move motion event from reaching the ListView. That works well, but if you touch one of the items in the list, and move your finger away from the view, the event bound to that item view still fires. The behavior the user usually expects is to cancel the event in this case – think of touching a button, and changing your mind mid-press. That can be done using a slightly more complex dispatchTouchEvent method. The complete class is below:


Now replace your ListView in the layout by the custom implementation, and you have a properly functioning static ListView.


4 Responses to “Disable scrolling in Android ListView”

  1. Fat Johnnie


Leave a Reply

  • (will not be published)