Search code examples
androidandroid-coordinatorlayoutandroid-appbarlayoutnestedscrollview

ListView not expanding inside NestedScrollView


I am using CoordinatorLayout in my activity page. In that there is ListView below the app bar. But its not working when I use ListView instead of NestedScrollView. And if I put ListView inside NestedScrollView, ListView is not expanding


Solution

  • 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.