Created
February 3, 2017 01:43
-
-
Save brendanw/be5e22bc2f9d54836e9ab309cd69c487 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
/** | |
* Need to return true here to continue hearing updates from the child | |
* for the duration of the scroll | |
*/ | |
public boolean onStartNestedScroll(View child, View target, int nestedScrollAxes) { | |
return true; | |
} | |
@Override | |
public void onNestedPreScroll(View target, int dx, int dy, int[] consumed) { | |
int [] pos = new int[2]; | |
target.getLocationOnScreen(pos); | |
if (pos[1] <= 0 && dy > 0) { | |
Log.d(TAG, "onNestedPreScroll: child consumes"); | |
//allow the child to consume the event | |
} else if (pos[1] <= 0 && target.getScrollY() > 0) { | |
Log.d(TAG, "onNestedPreScroll: child consumes"); | |
//allow the child to consume the event | |
} else { | |
Log.d(TAG, "onNestedPreScroll: parent consumes"); | |
//we consume the event | |
scrollBy(0, dy); | |
consumed[1] = dy; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment