Search code examples
androidandroid-layoutandroid-listviewandroid-scrollview

ScrollView including ListView in Android


I would like to have a ScrollView that contains a ListView, which is obviously undesirable since a ListView has its own scroll bar.

Essentially I would like to have a RelativeLayout with a number of views forming the header of the page, followed by a ListView, similar to Facebook's profile page with the images followed by the feed.

If I simply put a ListView inside a RelativeLayout then only the ListView area is scrollable instead of the whole page.

Is there a way to do this without including the header (RelativeLayout) as the first element in the ListView?


Solution

  • It looks like there is a method on ListView called addHeaderView. I can use this to add the RelativeLayout at the top. Thanks for your input.