title: Android: ScrollView does not re-size when adding child views
body: <p>I have a ScrollView that I am trying to populate dynamically. Here is the XML that contains the ScrollView:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="#f6f5f5" &gt;
  
  &lt;ScrollView
      android:id="@+id/scrollView1"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:background="#40ff0000"
      android:paddingBottom="70dp"
      android:paddingTop="20dp"
      android:paddingLeft="20dp"
      android:paddingRight="20dp"&gt;
  
      &lt;LinearLayout
          android:id="@+id/option_list_container"
          android:background="#40ffff00"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="vertical" &gt;
  
          &lt;TextView
              android:id="@+id/textView1"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:layout_marginBottom="20dp"
              android:background="#292929"
              android:paddingBottom="5dp"
              android:paddingLeft="15dp"
              android:paddingTop="5dp"
              android:text="Stap 3/5"
              android:textAppearance="?android:attr/textAppearanceMedium"
              android:textColor="@color/white" /&gt;
      &lt;/LinearLayout&gt;
  &lt;/ScrollView&gt;
  </code></pre>
  
  <p>
  </p>
  
  <p>And here is the XML for the element I'm inserting in the ScrollvVew:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:orientation="horizontal" &gt;
  
  &lt;np.custom.FontIcon
      android:id="@+id/option_icon"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:background="@drawable/calendar_circleround"
      android:textSize="40sp"
      android:gravity="center"
      android:text="@string/planit_selection_empty_circle"
      android:textColor="#292929" /&gt;
  
  &lt;TextView
      android:id="@+id/option_text"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:gravity="center_vertical"
      android:layout_marginLeft="10dp"
      android:textAppearance="?android:attr/textAppearanceMedium" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>This is the code I use to populate the scrollview:</p>
  
  <pre><code>    ArrayList&lt;String&gt; g = new ArrayList&lt;String&gt;();
      g.add("Fix a Bug");
      g.add("Buy a new PC");
      g.add("Make Coffee");
      g.add("Take a Break");
      g.add("Don't do that");
      g.add("Throw your hands in the air like you just don't care!");
      LinearLayout optionListLayout = (LinearLayout) rootView.findViewById(R.id.option_list_container);
      LayoutInflater inflater = LayoutInflater.from(getActivity());
      for(String p:g){
          View v = inflater.inflate(R.layout.planit_option_item, null);
          TextView optText = (TextView) v.findViewById(R.id.option_text);
          optText.setText(p);
          optionListLayout.addView(v);
      }
  </code></pre>
  
  <p>This all works almost fine, except that the sizes of the ScrollView and the LinearLayout it contains do not come out as I expected. This a screenshot of that it looks like on a device, which shows text being cut out when it goes to a second line:</p>
  
  <p><img src="https://i.stack.imgur.com/WKk4o.png" alt="enter image description here"></p>
  
  <p>So how can I make sure the linear layout re-sizes to accommodate children views of different heights?</p>