title: TableLayout (TableRow?) not sizing child Views as expected when adding them dynamically
body: <p><strong>Context:</strong> I have a TableLayout (created using XML), which has one TableRow, which has one TextView. The code:</p>
  
  <pre><code> &lt;ScrollView 
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:fillViewport="true"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     &gt;
    &lt;TableLayout
       android:id="@+id/mytable"
       android:orientation="vertical"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:stretchColumns="1"
       &gt;
      &lt;TableRow&gt;
        &lt;TextView
       android:id="@+id/add_alarm"
       android:layout_weight="1"
       android:layout_width="0dp"
       android:layout_height="fill_parent"
       android:gravity="center"
       android:text="New\nItem"
       android:textSize="30sp"
       /&gt;
      &lt;/TableRow&gt;
    &lt;/TableLayout&gt;
  &lt;/ScrollView&gt;
  </code></pre>
  
  <p>In my Activity's onCreate() method, I am trying to add another View to the TableRow dynamically. Here is the code:</p>
  
  <pre><code>    public void onCreate(Bundle savedInstanceState)    {
          super.onCreate(savedInstanceState);
          LayoutInflater inflater = LayoutInflater.from(this);
          View mainLayout = inflater.inflate(R.layout.main, null);
          TableLayout tl = (TableLayout) mainLayout.findViewById(R.id.mytable);
  
          TableRow tr = (TableRow) tl.getChildAt(0);
          Log.d(TAG, "tr class = " + tr.getClass().getName() + " | width = " + tr.getWidth() + "\n");
          final RelativeLayout rl = (RelativeLayout) inflater.inflate(R.layout.alarm_widget, null);
          LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1);
          tr.addView(rl, lp); 
          tl.invalidate();
          setContentView(mainLayout);
  }
  </code></pre>
  
  <p><strong>Question:</strong> This code is not having the intended effect of displaying both the Views (the one in the XML layout already &amp; the other added dynamically) in a columns of equal width.</p>
  
  <ol>
  <li>With the code given above, the dynamically added View has a width of '0' and is therefore invisible.</li>
  <li>If I change the code to <code>tr.addView(rl)</code> (i.e. without reference to LayoutParams), the dynamically added view is visible, but the columns are not equal in width.</li>
  </ol>
  
  <p>How can I achieve this?</p>
  
  <p><strong>Edit:</strong> I changed the code based on the comments to the following. It still doesn't work as expected:</p>
  
  <pre><code>TableLayout.LayoutParams lp = new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT,
                                 TableLayout.LayoutParams.WRAP_CONTENT, 1f);
  tr.addView(rl, lp); 
  </code></pre>