Design lib - CoordinatorLayout/CollapsingToolbarLayout with GridView/listView Design lib - CoordinatorLayout/CollapsingToolbarLayout with GridView/listView android android

Design lib - CoordinatorLayout/CollapsingToolbarLayout with GridView/listView


With ListView/GridView, it works only on Lollipop by following code-

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {     listView.setNestedScrollingEnabled(true);}

I think for Now CoordinatorLayout works only with RecyclerView and NestedScrollView

EDIT :

use -

ViewCompat.setNestedScrollingEnabled(listView/gridview,true); (add Android Support v4 Library 23.1 or +)


A simple solution was added to the support lib:

ViewCompat.setNestedScrollingEnabled(listView,true);

I've tested it with Android Support v4 Library 23.1 and it works well.


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.