Tag Archives: 2.1

Disable Android 2.3 View overscrolling on prior versions

Update Developers reported, that this does not work/misbehaves on several devices, so should be avoided.

Android Gingerbread enables by default overscrolling in default orange style, which could be disturbing in many layouts.
To disable it you can use the setOverScrollMode method with the OVER_SCROLL_NEVER parameter, however it is not available on prior Android versions.
Here is a safe solution for all Android versions:

public static void disableOverscroll(View view) {
Class viewCls = view.getClass();
try {
Method m = viewCls.getMethod("setOverScrollMode",
new Class[] { int.class });
int OVER_SCROLL_NEVER = (Integer) viewCls.getField(
m.invoke(view, OVER_SCROLL_NEVER);
} catch (Exception e) {
// swallow

By alex on Stackoverflow.com