You can use the static method setListViewHeightBasedOnChildren () of the Utility class below to achieve this: Call Utility. setListViewHeightBasedOnChilren (listview) after listview. Public class Utility {public static void setListViewHeightBasedOnChildren (ListView listView) {// obtain the AdapterListAdapter listAdapter = ListView corresponding to the listView. getAdapter (); if (listAdapter = null) {// pre-conditionreturn;} 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 );}}