nubela nubela - 1 year ago 84
Android Question

What are the new nested scrolling APIs for Android-L?

Answer Source

They did not draw much attention to this great new feature. I've been toying with it, and I think I've figured it out. All you have to do is is set


in the nested (child) scrollable view, assuming you have one somewhere inside another. This causes the child view to scroll to completion, and then allow its parent to consume the rest of the scroll. I found that I liked the opposite behavior better - parent gets scroll priority, then child follows - so I overrode the onNestedScroll method in ScrollView as follows:

public void onNestedScroll(View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
    //swap dyConsumed and dyUnconsumed
    super.onNestedScroll(target, dxConsumed, dyUnconsumed, dxUnconsumed, dyConsumed);

You should use this new ScrollView subclass for the outer (parent) ScrollView.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download