title: how can i automatically size listview so it doesn't scroll
body: <p>currently i have the following layout</p>
  
  <pre><code>&lt;LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true" 
      android:layout_alignParentRight="true" 
  
      android:layout_marginTop="9px" 
      android:layout_below="@+id/desc" 
      android:id="@+id/ll_item"  
      android:orientation="vertical" 
      android:paddingRight="3px" 
      android:paddingLeft="3px" 
      android:paddingBottom="5px" 
      android:paddingTop="5px" 
      android:background="@drawable/rounded_corner_lists" &gt;
  &lt;!--
          &lt;ListView android:drawSelectorOnTop="false" android:id="@+id/lv"    android:layout_height="fill_parent" android:layout_width="wrap_content" android:divider="#ddd" android:dividerHeight="1px" android:background="@drawable/white"    /&gt;
      --&gt;
      &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>the listview that i have commented out, i have tried to make this in the xml, with the height set to wrap_content, fill_parent, currently i am doing this programatically with the following code</p>
  
  <pre><code>LinearLayout ll_item = (LinearLayout) this.findViewById(R.id.ll_item);
          if(list.length() &gt; 0)
          {
              ll_item.setVisibility(View.VISIBLE);
              LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,calcListHeight(list));
  
              listview = new ListView(this);
              listview.setBackgroundResource(R.drawable.white);
              listview.setDivider( new ColorDrawable(this.getResources().getColor(R.drawable.dividercolor)) );
              listview.setDividerHeight(1);
              listview.setCacheColorHint(0);
  
              mAdapter  = new JSONAdapter( list, this );
              listview.setAdapter(mAdapter);
              mAdapter.notifyDataSetChanged();
              ll_item.addView(listview, lp);
          }
  </code></pre>
  
  <p>this is the result</p>
  
  <p><img src="https://i.stack.imgur.com/RY1TN.jpg" alt="alt text"></p>
  
  <p><img src="https://i.stack.imgur.com/BNsiH.jpg" alt="alt text"></p>
  
  <p>so you can see in this image, that since i'm containing the listview in a linearlayout to get the rounded corner look, it doesn't just automatically stretch to contain the entire listview,  is there any way to have the two elements just wrap the content vertically so there is no scrolling without me programatically setting the height ? ? ? </p>
  
  <p>i guess one other thing i should mention is that i have all this layout in a scrollview, because i want this listview to be a tiny subsection of the entire layout, so it would be something like </p>
  
  <p>-scrollview<br>
    -textview<br>
    -textview<br>
  <br>
    -linearlayout<br>
      -listview<br>
  <br>
    - button<br></p>
  
  <p>here is a simpler layout of what i have </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout android:orientation="vertical" android:layout_height="fill_parent" android:layout_width="fill_parent"
                android:background="@drawable/bg" xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/titlebar"&gt;
  
      &lt;ScrollView android:id="@+id/sv" android:layout_width="fill_parent" android:background="@drawable/bg"
                  android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  
          &lt;RelativeLayout android:id="@+id/widget28"
                          android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="4dip"
                  &gt;
  
  
              &lt;LinearLayout android:orientation="vertical" style="@style/rounded_corner_full_width_button"
                            android:id="@+id/editfields"&gt;
  
                  &lt;ListView android:drawSelectorOnTop="false" android:id="@+id/lv" android:layout_height="fill_parent"
                            android:layout_width="wrap_content" android:divider="#ddd" android:dividerHeight="1px"
                            android:background="@drawable/white"/&gt;
  
              &lt;/LinearLayout&gt;
          &lt;/RelativeLayout&gt;
      &lt;/ScrollView&gt;
  &lt;/LinearLayout&gt;
  </code></pre>