title: How to center a TableRow programmatically
body: <p>I am creating a number of buttons in a table row programmatically, but they always end up left-aligned. How can I center the entire row? I am trying this to create each row:</p>
  
  <pre><code>TableRow row = new TableRow(getActivity());
  TableLayout.LayoutParams params = new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL);
  row.setLayoutParams(params);
  
  for (int j = 0; j != numButtonCols; j++) {
      Button b = new Button(getActivity());
      b.setOnClickListener(actionListener);
      row.addView(b);
      actionButtons[j][i] = b;
  }
  
  layout.addView(row);
  </code></pre>