Is there a way to make table columns equal to a fraction of the total width?

So far in my training, I have come across the same distribution of column sizes, giving one / two higher priority, taking up as much space as they need, or manually setting the column size.

I was wondering if, in any case, setting the column size in Android would be part of the overall size of the table. I want to break it into the sixth. 1/6 for the first column, 3/6 for the second column and 2/6 for the third.

Is there any way to do this?

+6
android android-layout
source share
1 answer

You can do this using android: layout_span

Here is an example:

<?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:stretchColumns="*"> <TableRow android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:background="#aa0000" android:text="1/6" android:gravity="center_horizontal"/> <TextView android:background="#00aa00" android:text="3/6" android:gravity="center_horizontal" android:layout_span="3"/> <TextView android:background="#0000aa" android:text="2/6" android:gravity="center_horizontal" android:layout_span="2"/> </TableRow> </TableLayout> 
+18
source share

All Articles