views:

61

answers:

3

Hi,

I have a two column TableLayout as the only child of a scroll view. The first column contains TextViews ('labels') and the second column contains EditText/Spinner/DateWidget etc ('values'). Even though I have have specified android:layout_width="fill_parent" for TableLayout, TableRow & all widgets (in 'values' column).

The screen looks perfect when the activity is created. However, when one types a really long value in the EditText, the 'values' column goes beyond the visible screen area.

How do I tackle this?

Thanks

A: 

You may want to define the sizes of the columns by using a weight. So you will define the table layout width to fill parent but for each column you can should set the width to "0px" and the weight to the percentage you want the column to span. So assuming you want the first column to be 20% of the screen width you set it's weight to "0.2" and the second column to "0.8".

Try it and see if that works.

Savvas Dalkitsis
A: 

Try this, make sure android:singleLine="false" and android:inputType="textMultiLine":

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:stretchColumns="1">
    <TableRow android:layout_height="wrap_content"
        android:layout_width="fill_parent">

        <TextView android:text="Label:" />
        <EditText android:id="@+id/entry" android:inputType="textMultiLine"
            android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:singleLine="false" />
    </TableRow>
</TableLayout>
SteD