Search code examples
androidtextview

Long text in TextView


I want to display a long text in a TextView. This is my XML:

<TableLayout
    android:layout_width="fill_parent"
    android:layout_height="0dip"
    android:layout_weight="1" >

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="5dip"
            android:text="@string/text" />

        <TextView
            android:id="@+id/gender"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="right"
            android:text="@string/lorem" />
    </TableRow>
</TableLayout>

And this is how it looks like:
enter image description here
The long text doesn't fit. What do I have to change?


Solution

  • <TableLayout
            android:layout_width="fill_parent"
            android:layout_height="100dip"
            android:layout_weight="1" >
    
            <TableRow
                android:id="@+id/tableRow1"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" >
    
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="0.5"
                    android:padding="5dip"
                    android:text="@string/text" />
    
                <TextView
                    android:id="@+id/gender"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="0.5"
                    android:gravity="right"
                    android:text="@string/lorem" />
            </TableRow>
        </TableLayout>