title: How to get listview height in android?
body: <p>I need to find the height of android ListView with custom ListVAdapter. Each of ListView items can be of varying height. I have tried the following code which I found here:</p>
  
  <pre><code>public static void setListViewHeightBasedOnChildren(ListView listView) {
  
          ListAdapter listAdapter = listView.getAdapter(); 
          if (listAdapter == null) {
              return;
          }
  
          int totalHeight = 0;
          for (int i = 0; i &lt; listAdapter.getCount(); i++) {
              View listItem = listAdapter.getView(i, null, listView);
              listItem.measure(0, MeasureSpec.UNSPECIFIED);
              totalHeight += listItem.getMeasuredHeight();
          }
  
          ViewGroup.LayoutParams params = listView.getLayoutParams();
          params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
          listView.setLayoutParams(params);
          listView.requestLayout();
      } 
  </code></pre>
  
  <p>But it doesn't give actual height; it gives same height for all list items. Is it possible to find ListView height with list items of varying height?</p>