If the scrollview contains a listView, a sliding problem occurs .. The most common problem is that listview cannot slide... The cause is that the height of the listview should be determined according to the data bound by the adapter when it is loaded, rather than fill_parent or wrap_content...
If the project is used, extract it and make a record.
Import android. view. view; import android. view. viewGroup; import android. widget. listAdapter; import android. widget. listView; public class ListViewUtils {public void setListViewHeightBasedOnChildren (ListView listView) {// obtain the Adapter ListAdapter listAdapter = ListView corresponding to listView. getAdapter (); if (listAdapter = null) {return;} int totalHeight = 0; for (int I = 0, len = listAdapter. getCount (); I <len; I ++) {// listAdapter. getCount () returns the number of data items. View listItem = listAdapter. getView (I, null, listView); listItem. measure (0, 0); // calculate the width and height of the subitem View totalHeight + = listItem. getMeasuredHeight (); // calculate the total height of all subitems} ViewGroup. layoutParams params = listView. getLayoutParams (); params. height = totalHeight + (listView. getDividerHeight () * (listAdapter. getCount ()-1); // listView. getDividerHeight () obtains the height occupied by separators between subitems. // params. the height finally shows the required height for the entire ListView. setLayoutParams (params );}}
The specific usage is to use this util to dynamically determine the height after the listview binds the data adapter.