How do I stretch the TextView so it fills the entire TableRow height? Here is a screenshot of what I’m getting right now,

I want the TextView to expand with the TableRow.
Here is how I create the row:
row = new TableRow(this);
desc = new TextView(this);
desc.setBackgroundResource(R.drawable.borders);
desc.setTypeface(Typeface.SERIF, Typeface.BOLD);
desc.setText("Production Date");
desc.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT));
String date = gendataObj.getString("date");
text = new TextView(this);
text.setBackgroundResource(R.drawable.borders);
text.setText(date);
text.setGravity(Gravity.LEFT);
text.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT));
row.addView(desc);
row.addView(text);
table.addView(row, new TableLayout.LayoutParams(
TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
Change:
to:
Because otherwise, you don’t specify height (just width), which by default will remain as
WRAP_CONTENTwhich causes yourTextViewto be as heigh as it’s content (text).