A ListView which its height can wrap content even if it is nested in a ScrollView.
Although it's not a good idea to nest a ListView in a ScrollView, in Android Studio, a warning will be given after inspections:
Nested scrolling widgets
A scrolling widget such as a ScrollView should not contain any nested scrolling widgets since this has various usability issues
But if you really want to, this WrapContentListView can be a solution.
Use normal ListView
Use this WrapContentListView
<org.mazhuang.wrapcontentlistview.WrapContentListView
android:id="@+id/list_wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</org.mazhuang.wrapcontentlistview.WrapContentListView>
and you should call notifyDataSetChanged();
after dataset in ListAdapter changed.