title: Why get Height of ListView not correct?
body: <p>This is my function calculator Height of ListView:</p>
  <pre><code> fun setListViewHeightBasedOnChildren(listView: ListView) {
          val listAdapter = listView.getAdapter() ?: return
  
          val desiredWidth = MeasureSpec.makeMeasureSpec(listView.getWidth(), MeasureSpec.UNSPECIFIED)
          var totalHeight = 0
          var view: View? = null
          for (i in 0 until listAdapter.getCount()) {
              view = listAdapter.getView(i, view, listView)
              if (i == 0)
                  view!!.layoutParams = ViewGroup.LayoutParams(desiredWidth, LinearLayout.LayoutParams.WRAP_CONTENT)
  
              view!!.measure(desiredWidth, MeasureSpec.UNSPECIFIED)
              totalHeight += view.measuredHeight 
          }
          val params = listView.getLayoutParams()
          params.height = totalHeight + listView.getDividerHeight()  * (listAdapter.getCount() - 1)
          listView.setLayoutParams(params)
      }
  </code></pre>
  <p>And call display all items:</p>
  <pre><code> setListViewHeightBasedOnChildren(listView)
  </code></pre>
  <p>Result: last row not display ok:
  <a href="https://i.stack.imgur.com/08tzP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/08tzP.png" alt="enter image description here" /></a></p>
  <p>Why get Height of ListView not correct?</p>