Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

I'm unable to find this info at https://developer.android.com/preview/api-overview.html

Thanks!

like image 579
nubela Avatar asked Aug 05 '14 10:08

nubela


People also ask

What is nested scrolling android?

NestedScrollView is just like ScrollView, but it supports acting as both a nested scrolling parent and child on both new and old versions of Android. It is enabled by default. NestedScrollView is used when there is a need for a scrolling view inside another scrolling view.

What is nestedScrollingEnabled?

android:nestedScrollingEnabled="true" 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.

How do I stop NestedScrollView scrolling?

setnestedscrollingenabled set it to false.


1 Answers

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

android:nestedScrollingEnabled="true"

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:

@Override 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.

like image 130
guyIntrepid Avatar answered Oct 05 '22 16:10

guyIntrepid