views:

617

answers:

2

I have the following layout defined for one of my Activities:

<?xml version="1.0" encoding="utf-8"?>
<TableLayout android:id="@+id/TableLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"&gt;
    <TableRow android:id="@+id/TableRow01" android:layout_height="wrap_content" android:layout_width="fill_parent">
        <EditText android:text="Resource Name" android:id="@+id/ResourceName" android:lines="1" android:isScrollContainer="false"></EditText>
    </TableRow>
    <TableRow android:id="@+id/TableRow02" android:layout_height="wrap_content" android:layout_width="fill_parent">
        <Button android:id="@+id/Tile" android:text="Tile"></Button>
    </TableRow>
</TableLayout>

The layout renders almost correctly, the only problem is that my text box and my button aren't occupying the full width of their respective rows.

I've tried specifying fill_parent for the layout width properties, but to no avail, they still only occupy roughly half of the screen.

Documentation overall for Android so far has been great, but there are a few scenarios like this one where I hit an invisible wall! Thanks for all the help!

+4  A: 

try using android:stretchColumns="1" (when you define the TableLayout) or what ever is the index of the column that you would want to stretch.

For more information - http://developer.android.com/guide/tutorials/views/hello-tablelayout.html

Rahul
Ah, looking it up in the API, the value "*" (or a comma delimited list of columns starting from 0) worked.Thanks!
Omega
+2  A: 

Try this in the definition of your TableRow :

<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1">
Sephy
It looks like the columns index starting at 0, but yes, this is it! Apologies, I wish I could choose two correct answers ;)
Omega