Skip to content

Instantly share code, notes, and snippets.

@peterkuterna
Forked from DHuckaby/OverscrollUtilities.java
Created October 1, 2013 21:07
Show Gist options
  • Save peterkuterna/6785122 to your computer and use it in GitHub Desktop.
Save peterkuterna/6785122 to your computer and use it in GitHub Desktop.
public class OverscrollUtilities {
public static void disableOverscrollMode(View view) {
if (view instanceof ListView) {
try {
ListView listView = (ListView) view;
Method setEnableExcessScroll = ListView.class.getMethod("setEnableExcessScroll", Boolean.TYPE);
if (setEnableExcessScroll != null) {
setEnableExcessScroll.invoke(listView, Boolean.valueOf(false));
}
} catch (Exception ignore) {
// Silently ignore
}
}
try {
int OVER_SCROLL_NEVER = View.class.getField("OVER_SCROLL_NEVER").getInt(null);
Method setOverScrollMode = View.class.getMethod("setOverScrollMode", new Class[] { Integer.TYPE });
if (setOverScrollMode != null) {
setOverScrollMode.invoke(view, OVER_SCROLL_NEVER);
}
} catch (Exception ignore) {
// Silently ignore
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment