It works for me, hope this helps to you as well
Iam looping 3 times so 3 rows will add,added picture below
TableRow tr = new TableRow(getActivity());
tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT,2));
tr.setGravity(Gravity.CENTER_VERTICAL);
TextView labelText = new TextView(getActivity());
labelText.setText(key + " ");
labelText.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT,0.7f));
labelText.setGravity(Gravity.LEFT);
labelText.setTextSize(8);
labelText.setPadding(5, 0, 5, 0);
tr.addView(labelText);
View seperatorView = new View(getActivity());
seperatorView.setLayoutParams(new TableRow.LayoutParams(2, TableRow.LayoutParams.MATCH_PARENT));
seperatorView.setBackgroundColor(getResources().getColor(R.color.radio_border_color));
tr.addView(seperatorView);
TextView valueText = new TextView(getActivity());
valueText.setText(value);
valueText.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT, 1.3f));
valueText.setGravity(Gravity.LEFT);
valueText.setTextSize(8);
valueText.setMinLines(1);
valueText.setMaxLines(Integer.MAX_VALUE);
valueText.setPadding(5, 0, 5, 0);
tr.addView(valueText);
barcodeTableLayout.addView(tr);