How to set padding to columns in table layout dynamically
- by Praveenb
Hi all,
I am trying to create a table layout with buttons dynamically. I am able to get the table layout with buttons. bt i need padding between buttons. How i can get programatically.
I tried following code bt
private void showCowsTblField()
{
for (int row = 0; row < numberOfRowsInField-1; row++)
{
TableRow tableRow = new TableRow(this);
tableRow.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT ));
for (int column = 0; column < numberOfColumnsInField -1; column++)
{
blocks[row][column].setLayoutParams(new LayoutParams(
LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
blocks[row][column].setPadding(blockPadding, blockPadding, blockPadding, blockPadding);
tableRow.addView(blocks[row][column]);
tableRow.setPadding(blockPadding, blockPadding, blockPadding, blockPadding);
}
tblCows.addView(tableRow,new TableLayout.LayoutParams(
LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
}
}
Please let me know.... Thanks.