tags:

views:

224

answers:

2

Hello everyone. I've noticed a strange thing with a TableRow.

        <TableLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:stretchColumns="0">

        <TableRow
            android:background="#9932cc"
            android:minHeight="40px"
            android:orientation="horizontal">

            <LinearLayout
                android:paddingLeft="10px"
                android:paddingRight="10px"
                android:gravity="center_vertical"

                android:layout_gravity="center_vertical"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"

                android:orientation="horizontal">

                <ImageView
                    android:background="@drawable/circle_checkmark"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_vertical" />

                <TextView
                    android:id="@+id/text1"
                    android:background="#ffffff"
                    android:textColor="#161616"
                    android:text="11111 11111 11111 11111 11111 11111 11111 11111 11111 "

                    android:layout_gravity="center_vertical"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />
            </LinearLayout>
        </TableRow>

    </TableLayout>

This code doesn't work properly as TextView text1 doesn't wrap it just stretches beyond the screen. I've managed to get it working by embedding this LinearLayout into RelativeLayout but it seems to be the least elegant solution plus I don't understand what's wrong with the code above...

A: 

Sorry ignore that. Appears to be ADT or Eclipse bug. Now all works as it should

        <TableRow
            android:background="#9932cc"
            android:minHeight="40px"
            android:orientation="horizontal"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:paddingLeft="3dip"
            android:paddingRight="3dip">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/circle_checkmark" />

            <TextView
                android:id="@+id/text1"
                android:background="#ffffff"
                android:textColor="#161616"
                android:text="Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello "

                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

        </TableRow>
Kostia Dombrovsky
A: 

You can also mark the column containing the text as "shrinkable" (cf the javadoc).

Romain Guy