ListView not expanding inside NestedScrollView

on Lollipop onwards you can use

setNestedScrollingEnabled(true);

on your ListView/GridView/ScrollableView. From the documentation

Enable or disable nested scrolling for this view

if you need backwards compatibility with older version of the OS you'll have to use the RecyclerView. You can read more here

Edit. ViewCompat has the static method setNestedScrollingEnabled(View, boolean). Eg.

ViewCompat.setNestedScrollingEnabled(listView, true)

thanks to @Dogcat for pointing it out


For the CoordinatorLayout to work properly you need the scrolling child to implement NestedScrollingChild. Such classes are NestedScrollView and RecyclerView.

To say it short - just use a RecyclerView for your scrolling content and it'll work correctly :)

P.S. As a side note, I don't see a reason why you'd use a ListView anymore. I know it's a habit and it's easier to setup (because you've done it many times), but using a RecyclerView is the recommended way anyways.


you can fix it when you add addtribute android:fillViewport="true" in android.support.v4.widget.NestedScrollView :) . This my code.

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="none"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    android:fillViewport="true"
    >
    <ListView
        android:id="@+id/list_myContent"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="vertical"
        >
    </ListView>

</android.support.v4.widget.NestedScrollView>