title: How can I programmatically set this tablelayout to have equal column widths for Android?
body: <p>I am trying to create the rows below the table heading programmatically, but they are spilling over and I am not sure how to split them up to only take up 25% of the width each? </p>
  
  <p>Here is the code for the row creation:</p>
  
  <pre><code>TableRow row = new TableRow(activity);
  lp = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.MATCH_PARENT, 1.0f);
  tl = new TableLayout.LayoutParams();
  
  tl.weight = 1;
  lp.height = 100;
  
  row.setLayoutParams(lp);
  row.setWeightSum(4);
  
  
  tv = new TextView(getActivity());
  tv.setLayoutParams(tl);
  tv.setTextSize(14);
  tv.setText(whotos.get(i));
  
  tv2 = new TextView(getActivity());
  tv2.setLayoutParams(tl);
  tv2.setTextSize(14);
  tv2.setText(documents.get(i));
  
  tv3 = new TextView(getActivity());
  tv3.setLayoutParams(tl);
  tv3.setTextSize(14);
  tv3.setText(directions.get(i));
  
  tv4 = new TextView(getActivity());
  tv4.setLayoutParams(tl);
  tv4.setTextSize(14);
  tv4.setText(thedates.get(i));
  
  
   row.addView(tv);  //tp name
  row.addView(tv2); //document type
  row.addView(tv3); //direction
  row.addView(tv4); //date
  
  ll.addView(row, i + 1 + tableHeadingRows);
  </code></pre>
  
  <p>Here is my code for the layout above the programmatically created rows:</p>
  
  <pre><code>&lt;TableRow
              android:id="@+id/tableRow2"
              android:layout_width="0dp"
              android:layout_height="wrap_content"
              android:padding="5dip"
              android:stretchColumns="1"
              android:weightSum="4"&gt;
  
              &lt;TextView
                  android:id="@+id/tp"
                  android:layout_weight="1"
                  android:layout_width="0dp"
                  android:text="TP"
                  android:textAppearance="?android:attr/textAppearanceLarge" /&gt;
              &lt;TextView
                  android:id="@+id/doc"
                  android:layout_weight="1"
                  android:layout_width="0dp"
                  android:text="Doc"
                  android:textAppearance="?android:attr/textAppearanceLarge" /&gt;
              &lt;TextView
                  android:id="@+id/dir"
                  android:layout_weight="1"
                  android:layout_width="0dp"
                  android:text="Direction"
                  android:textAppearance="?android:attr/textAppearanceLarge" /&gt;
              &lt;TextView
                  android:id="@+id/date"
                  android:layout_weight="1"
                  android:layout_width="0dp"
                  android:text="Date"
                  android:textAppearance="?android:attr/textAppearanceLarge" /&gt;
          &lt;/TableRow&gt;
  
          &lt;!-- draw a red line --&gt;
          &lt;View
              android:layout_height="2dip"
              android:background="@color/tableHorizontalRule" /&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/6wGDn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6wGDn.png" alt="Image with columns stretching too far below headers, censored names and info"></a></p>
  
  <p>Does anyone have a solution to this issue?</p>