tags:

views:

30

answers:

1

My Android app displays data in a table. How do I display a grid separating the cells, so that it's easier to visually follow rows and columns? I didn't find any option pertaining to grid in the android.widget.TableLayout class...

Michael

+1  A: 

You should use backgroud color and margins as follows.

 <TableLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:stretchColumns="*" android:background="#ff00f0">
     <TableRow android:layout_margin="2dp" android:background="#000000">
        <TextView android:text="first" />
        <TextView android:text="second" />
        <Button android:text="third" />
   </TableRow>
 </TableLayout>
Ankit Jain
Your example creates a visible frame around the entire table (which is a first step) but not the individual cells. How would I do *that*?
mmo
you gotto do `android:layout_margin="2dp" android:background="#000000"` for both inner cells i.e. `TextView`
Ankit Jain