Just to add you can change it dynamically too
int left = 6;
int top = 12;
int right = 6;
int bottom = 6;
TableRow.LayoutParams params = new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.setMargins(left, top, right, bottom);
EditText edXY = new EditText(inventory.this);
edXY.setLayoutParams(params);