I found this example
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TableLayout layout = new TableLayout (this);
layout.setLayoutParams( new TableLayout.LayoutParams(20,20) );
layout.setPadding(1,1,1,1);
for (int f=0; f<=3; f++) {
TableRow tr = new TableRow(this);
tr.setPadding(10,10,10,10);
for (int c=0; c<=3; c++) {
Button b = new Button (this);
b.setText(""+f+c);
b.setTextSize(10.0f);
b.setPadding(10, 10, 10, 10);
b.setTextColor(Color.rgb( 100, 200, 200));
b.setBackgroundColor(Color.BLUE);
b.setOnClickListener(this);
b.setWidth(24);
b.setHeight(24);
tr.addView(b);
} // for
layout.addView(tr);
} // for
super.setContentView(layout);
} // ()
I need to have matrix of buttons ( something like GridLayout in Java ). The problem in this code is that I don't have any space between columns in same row. How to add space between buttons in same row ?