I have TableRows created dynamically in the code and I want to set margins for these TableRows.
My TableRows created as follow
This is working:
TableRow tr = new TableRow(...);
TableLayout.LayoutParams lp =
new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT);
lp.setMargins(10,10,10,10);
tr.setLayoutParams(lp);
------
// the key is here!
yourTableLayoutInstance.addView(tr, lp);
You need to add your TableRow to TableLayout passing the layout parameters again!