<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="3"
android:id="@+id/tableLayout"
>
<TableRow>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="0dp"
android:weightSum="3">
<View android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
</View>
<View android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
</View>
<View android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
</View>
</LinearLayout>
</TableLayout>
TableLayout tl=(TableLayout)findViewById(R.id.tableLayout);
TableRow tr1 = new TableRow(this);
tr1.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
t1.addView(tr1);
LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.HORIZONTAL);
//LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(width, height, weight);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0dp,LayoutParams.WRAP_CONTENT, 3);
tr1.addView(ll, params);
View v1= new View(this);
View v2= new View(this);
View v3= new View(this);
ll.addView(v1, new LayoutParams(0dp, LayoutParams.WRAP_CONTENT,1));
ll.addView(v2, new LayoutParams(0dp, LayoutParams.WRAP_CONTENT,1));
ll.addView(v3, new LayoutParams(0dp, LayoutParams.WRAP_CONTENT,1));