-
-
Save peterkuterna/6785122 to your computer and use it in GitHub Desktop.
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) { | |
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