table layout wrapping text android

android

Solution

For each `TextView` in `TableRow` replace "match_parent" with 0dp and use weight instead.

Change the line:

android:layout_width="match_parent"

To the lines:

android:layout_width="0dp"
android:layout_weight="1"

if you want a column to be bigger than others, just change weight from 1 to a bigger number.

Problem

I'm creating dynamic table. The first row is static. ``` <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#DEDEDE" > <TableLayout android:id="@+id/TableLayout1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#DEDEDE" > <TableRow android:id="@+id/tableRow1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@color/DarkGray" > <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:textColor="@color/Black" android:background="@drawable/cell_shape" android:text="Аватар" android:textSize="16dp" android:textStyle="bold" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:textColor="@color/Black" android:background="@drawable/cell_shape" android:text="Выезд" android:textSize="16dp" android:textStyle="bold" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/cell_shape" android:text="Откуда" android:textColor="@color/Black" android:textSize="16dp" android:textStyle="bold" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/cell_shape" android:text="Куда" android:textColor="@color/Black" android:textSize="16dp" android:textStyle="bold" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:textColor="@color/Black" android:background="@drawable/cell_shape" android:text="М/Ц" android:textSize="16dp" android:textStyle="bold" /> </TableRow> </TableLayout> </ScrollView> ``` the second one and other rows are dynamic, and they are filled programmatically ``` <?xml version="1.0" encoding="utf-8"?> <TableRow xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/TableRow1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#DEDEDE" > <ImageView android:id="@+id/imageStatus" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/cell_shape" /> <TextView android:id="@+id/textVuezd" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/cell_shape" android:text="" android:textColor="@color/Black" android:textSize="12dp" /> <TextView android:id="@+id/textOtkuda" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/cell_shape" android:text="" android:textColor="@color/Black" android:textSize="12dp" /> <TextView android:id="@+id/textKuda" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/cell_shape" android:text="" android:textColor="@color/Black" android:textSize="12dp" /> <TextView android:id="@+id/textSeatsPrice" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/cell_shape" android:text="" android:textColor="@color/Black" android:textSize="12dp" /> </TableRow> ``` I show this table as dialog and got this: ``` http://www.autostarkiev.com.ua/gg.png ``` due to font size I can see only half of the whole table. How do I make text in text view wrap, so i can see the whole table?

Original source