10

I am developing a screen that uses TableLayout. Here I am easily able to create two columns. but how can I create three columns ?

Lucifer
  • 29,392
  • 25
  • 90
  • 143

2 Answers2

18

Here an example:

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:stretchColumns="1">
    <TableRow>
        <TextView
            android:text="first"
            android:padding="3dip" />
        <TextView
            android:text="second"
            android:gravity="center"
            android:padding="3dip" />
        <TextView
            android:text="third"
            android:gravity="right"
            android:padding="3dip" />
    </TableRow>

    <TableRow>
        <TextView
            android:text="first"
            android:padding="3dip" />
        <TextView
            android:text="second"
            android:gravity="center"
            android:padding="3dip" />
        <TextView
            android:text="third"
            android:gravity="right"
            android:padding="3dip" />
    </TableRow>
</TableLayout>
Yury
  • 20,618
  • 7
  • 58
  • 86
2

For each TableRow you have to add three children instead of two. This should be ok for you!

Hope this helps!

Dimitris Makris
  • 5,183
  • 2
  • 34
  • 54