To make 1dp collapse-border around every cell without writing a java code and without creating another xml layout with <shape...>
tag, you can try this solution:
In <TableLayout...>
add
android:background="#CCC"
and android:paddingTop="1dp"
and android:stretchColumns="0"
In <TableRow...>
add
android:background="#CCC"
and android:paddingBottom="1dp"
and android:paddingRight="1dp"
In every cell/child in TableRow, i.e. <TextView...>
add
android:background="#FFF"
and android:layout_marginLeft="1dp"
It is very important to follow paddings and margins as described. This solution will draw a 1dp border aka border-collapse property in (X)HTML/CSS.
Background color in <TableLayout...>
and <TableRow...>
represents a border line color and background in <TextView...>
fills a table cell. You can put some padding in cells if necessary.
An example is here:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#CCC"
android:paddingTop="1dp"
android:stretchColumns="0"
android:id="@+id/tlTable01">
<TableRow
android:background="#CCC"
android:paddingBottom="1dp"
android:paddingRight="1dp">
<TextView
android:layout_marginLeft="1dp"
android:padding="5dp"
android:background="#FFF"
android:text="Item1"/>
<TextView
android:layout_marginLeft="1dp"
android:padding="5dp"
android:background="#FFF"
android:gravity="right"
android:text="123456"/>
</TableRow>
<TableRow
android:background="#CCC"
android:paddingBottom="1dp"
android:paddingRight="1dp">
<TextView
android:layout_marginLeft="1dp"
android:padding="5dp"
android:background="#FFF"
android:text="Item2"/>
<TextView
android:layout_marginLeft="1dp"
android:padding="5dp"
android:background="#FFF"
android:gravity="right"
android:text="456789"/>
</TableRow>
</TableLayout>