Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: displaying long text for TextView

I have to display a long text about 250 chars (single line, no new line chars. or breaks). for a TextView of my activity.

I have used textType as textMultiLine for my layout's view and from activity I used view.setText() method by passing the long text.

But the text is displaying out of the visible screen.

How to fix this?

Thanks, Nehatha

+++ Edit +++++

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="vertical" android:background="@drawable/bg" 
android:gravity="center_horizontal"
android:id="@+id/rootView">
<ScrollView android:id="@+id/ScrollView01"
    android:layout_width="wrap_content" android:layout_height="wrap_content" 
    android:layout_marginLeft="8dp" android:layout_marginRight="8dp"
    android:minWidth="310dp" android:scrollbarStyle="outsideOverlay"
    android:scrollbars="vertical">
        <LinearLayout android:orientation="vertical"
            android:layout_width="fill_parent" android:layout_height="fill_parent">
            <FrameLayout android:id="@android:id/tabcontent"
                android:layout_width="fill_parent" android:layout_height="fill_parent">


                <LinearLayout android:id="@+id/tabContentPostDetails"
                    android:layout_width="wrap_content" android:orientation="vertical"
                    android:layout_height="fill_parent">

                    <TableLayout android:id="@+id/TableLayout01"
                        android:layout_width="fill_parent" android:layout_height="wrap_content"
                        android:gravity="center"
                        android:background="@drawable/transparent_border_shape">
                        <TableRow android:layout_marginBottom="5dip">
                            <LinearLayout android:orientation="horizontal"
                            android:layout_width="fill_parent" android:layout_height="wrap_content">
                                <TextView android:id="@+id/csPostTitle"
                                    android:padding="3dip" android:textSize="7pt"
                                    android:textColor="@color/Black"  
                                    android:layout_width="fill_parent" android:layout_height="wrap_content" android:inputType="textMultiLine"/>
                            </LinearLayout>
                        </TableRow>

                        ....
like image 909
Venkat Papana Avatar asked Feb 23 '26 21:02

Venkat Papana


2 Answers

You are probably using layout_width="wrap_content". This will make the TextView stretch to contain your text in a single line. Try using layout_width="fill_parent" (or a given width), and layout_height="wrap_content".

like image 132
Gregory Avatar answered Feb 25 '26 10:02

Gregory


try android:maxEms="15" .i think it will help you

like image 30
Roman Marius Avatar answered Feb 25 '26 11:02

Roman Marius



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!