title: TextView layout_gravity not working programmatically
body: <p>I've been looking around and have found many possible solutions for centering a textview in a layout. But none worked for me.
  My textview is in a TableLayout which is described by the following xml:</p>
  
  <pre><code>&lt;LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/schedule_main_holder"&gt;
      &lt;TableLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:stretchColumns="0"
        android:id="@+id/schedule_table_entry"&gt;
     &lt;/TableLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>What I'm doing is making a new TableRow and then adding a TextView and a ListView to it...but the textview has to be centered vertically. For that I'm doing:</p>
  
  <pre><code>TableRow row = new TableRow(this);
  
          TextView tview = new TextView(this);
          tview.setText("Wednesday");
          TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER_VERTICAL);
          tview.setLayoutParams(layoutParams);
          row.addView(tview);
  </code></pre>
  
  <p>The problem is that the TextView is always on top of the cell and not in the middle as it should.
  I've tried a mix of combinations (even the FrameLayout method describe in another response) and I can't get the textview to be centered in the table cell.</p>
  
  <p>Thanks in advance</p>