Create TableLayout programmatically

Just to make the answer more clear: TableLayout.LayoutParams tableParams = new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT); TableRow.LayoutParams rowParams = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); TableLayout tableLayout = new TableLayout(context); tableLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));// assuming the parent view is a LinearLayout TableRow tableRow = new TableRow(context); tableRow.setLayoutParams(tableParams);// TableLayout is the parent view TextView textView = new TextView(context); textView.setLayoutParams(rowParams);// TableRow is the parent … Read more

Multiline TextView in Android?

If the text you’re putting in the TextView is short, it will not automatically expand to four lines. If you want the TextView to always have four lines regardless of the length of the text in it, set the android:lines attribute: <TextView android:id=”@+id/address1″ android:gravity=”left” android:layout_height=”fill_parent” android:layout_width=”wrap_content” android:maxLines=”4″ android:lines=”4″ android:text=”Lorem ipsum dolor sit amet, consectetur adipisicing … Read more

How is a CSS “display: table-column” supposed to work?

The CSS table model is based on the HTML table model http://www.w3.org/TR/CSS21/tables.html A table is divided into ROWS, and each row contains one or more cells. Cells are children of ROWS, they are NEVER children of columns. “display: table-column” does NOT provide a mechanism for making columnar layouts (e.g. newspaper pages with multiple columns, where … Read more

Programmatically adding TableRow to TableLayout not working

Got it, every LayoutParams should be of android.widget.TableRow.LayoutParams except one that supplied to tl.addView(…) /* Find Tablelayout defined in main.xml */ TableLayout tl = (TableLayout) findViewById(R.id.SaleOrderLines); /* Create a new row to be added. */ TableRow tr = new TableRow(this); tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT)); /* Create a Button to be the row-content. */ Button b = … Read more

Colspan all columns

Just use this: colspan=”100%” It works on Firefox 3.6, IE 7 and Opera 11! (and I guess on others, I couldn’t try) Warning: as mentioned in the comments below this is actually the same as colspan=”100″. Hence, this solution will break for tables with css table-layout: fixed, or more than 100 columns.