0

Text data set to the textView22 exceeds the width . Ideally the remaining text should come in the next line of the same table row , but the text is truncated. How to display the text in a multiple lines in the same TableRow ?

Code below has a single row with two columns.

 <TableLayout android:id="@+id/first_table"
                android:layout_width="match_parent" android:layout_height="match_parent"
                android:background="@drawable/table_shape" android:layout_marginTop="10dp"
                android:layout_marginLeft="20dp" android:layout_marginRight="20dp">
    <TableRow android:id="@+id/tableRow2" android:layout_width="wrap_content"
                        android:layout_height="wrap_content" android:isScrollContainer="true">
                        <TextView android:id="@+id/textView21"
                            android:layout_width="fill_parent" android:layout_height="wrap_content"
                            android:padding="5dp" android:textColor="@color/black"
                            android:text="@string/to_" android:textAppearance="?android:attr/textAppearanceMedium"
                            android:layout_gravity="right">
                        </TextView>
                        <TextView android:id="@+id/textView22"
                            android:layout_width="fill_parent" android:layout_height="wrap_content"
                            android:padding="5dp" android:textColor="@color/black"
                            android:textAppearance="?android:attr/textAppearanceMedium"
                            android:layout_gravity="left" android:maxLines="10"
                            android:scrollbars="vertical">
                        </TextView>
                    </TableRow>
    </TableLayout>
chiranjib
  • 5,288
  • 8
  • 53
  • 82

2 Answers2

0

use this code

in java

textview.setMovementMethod(new ScrollingMovementMethod());

in xml

android:maxLines="50"  // depends on your requirement            
android:scrollbars="vertical"  
RajaReddy PolamReddy
  • 22,428
  • 19
  • 115
  • 166
0

I have removed maxLines and added android:shrinkColumns="1" in TableLayout

ref link

try this code in xml

<?xml version="1.0" encoding="utf-8"?>

<TableRow
    android:id="@+id/tableRow2"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#FF0000" >

    <TextView
        android:id="@+id/textView21"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:text="Hellllo"
        android:textColor="#FFFFFF"
        android:textSize="20dip" >
    </TextView>

    <TextView
        android:id="@+id/textView22"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:text="Hellllossssssssssss Hellllossssssssssss Hellllossssssssssss Hellllossssssssssss Hellllossssssssssss Hellllossssssssssss Hellllossssssssssss Hellllossssssssssss Hellllossssssssssss Hellllossssssssssss Hellllossssssssssss vHellllossssssssssss Hellllossssssssssss vHellllossssssssssss Hellllossssssssssss Hellllossssssssssss Hellllossssssssssss Hellllossssssssssss"
        android:textColor="#FFFFFF"
        android:textSize="20dip" >
    </TextView>
</TableRow>

Community
  • 1
  • 1
Chirag Patel
  • 2,320
  • 3
  • 24
  • 38