There is an error in my code, LayoutParams is the wrong class, I should have used TableRow.LayoutParams
instead of TableLayout.LayoutParams
, so:
row.addView(t, new TableRow.LayoutParams(0, TableRow.LayoutParams.WRAP_CONTENT, 1f));
works as expected.