Rupal Rupal - 22 days ago 6
Android Question

Android layout: how to get button width across remaining "columns" in table row?

I've got a couple of table rows in a table layout. The last row got a button which I would like to stretch out to right side (i.e. fill the remaining space on right side in the row). When I try to stretch this button, other buttons in the row above also get stretched, which I don't want to happen. See image link for what I'm trying to achieve. The green button is supposed to go over "three columns".

Any tip on how I can do this?

Image for table row

Answer

you may try something like this

<TableRow android:layout_width="fill_parent"
        android:weightSum="100" android:layout_height="wrap_content">
        <Button android:text="Button" android:layout_weight="20"
            android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
        <Button android:text="Button" android:layout_width="wrap_content"
            android:layout_weight="20" android:layout_height="wrap_content"></Button>
        <Button android:text="Button" android:layout_weight="40"
            android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
    </TableRow>