This might be silly question but I didn\'t understand Design lib well. I am following this reference to create below layout. The Blue area should work as parallax when I scr
Currently the ListView
and the GridView
have the expected behavior with the CoordinatorLayout
only with API>21.
To obtain this behavior you have to set:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
setNestedScrollingEnabled(true);
}
It is not enough to implement the NestedScrollingChild
.
The AbsListView
isn't deployed with support libraries , then it depends by the SO running in the device.
You have to override some methods in the AbsListView. For example you can check the onInterceptTouchEvent
method.
Inside this code you can see:
case MotionEvent.ACTION_DOWN: {
//......
startNestedScroll(SCROLL_AXIS_VERTICAL);
//....
}
case MotionEvent.ACTION_MOVE: {
//.....
if (startScrollIfNeeded((int) ev.getX(pointerIndex), y, null)) {
//....
}
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP: {
//..
stopNestedScroll();
break;
}
This code is only in the implementation of AbsListView v21+. If you check the AbsListView with API 20 or lower, you will not find any nested scroll reference.