Last active
October 11, 2015 21:08
-
-
Save DHuckaby/3919939 to your computer and use it in GitHub Desktop.
Disable overscrolling on newer platforms, disable excess scrolling on certain Samsung devices
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OverscrollUtilities { | |
public static void disableOverscrollMode(View view) { | |
if (view instanceof ListView) { | |
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB && "samsung".equalsIgnoreCase(Build.MANUFACTURER)) { | |
try { | |
ListView listView = (ListView) view; | |
Method setEnableExcessScroll = ListView.class.getMethod("setEnableExcessScroll", Boolean.TYPE); | |
if (setEnableExcessScroll != null) { | |
setEnableExcessScroll.invoke(listView, Boolean.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 | |
} | |
} | |
} |
is the behaviour the one where it jumps back up the list when it reaches the end. I get this when setting the overscroll mode to OVER_SCROLL_NEVER
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It looks like some HTC devices contain the method setEnableExcessScroll and disabling it causes weird behavior at the end of the ListView, hence enabling it only on Samsung < 3.0 devices.