简体   繁体   中英

How to Put Long Text In TextView Android in MultiLines using Android ?

Here i am getting data dynamically from database now need to show data in textview but textview not displaying whole text while some text from right is going to be cut how to overcome in this situation ?

<LinearLayout 
    android:id="@+id/question_layout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp">
    <TableLayout 
        android:id="@+id/questiontable_tablelayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_marginLeft="3dp"
        android:layout_marginRight="3dp"
        android:layout_below="@+id/question_heading_layout">
    </TableLayout>
</LinearLayout> 

Another File of its TableRow

<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/questiontable_tablerowlayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

    <ScrollView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:scrollbars="none" >

            <LinearLayout
                android:id="@+id/questiontable_linearlayout"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="2dp"
                android:layout_marginRight="2dp"
                android:orientation="vertical" >

                <TextView
                    android:id="@+id/question_textview"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="left"
                    android:layout_marginLeft="2dp"
                    android:layout_marginRight="2dp"
                    android:layout_marginTop="2dp"
                    android:inputType="textMultiLine"
                    android:ellipsize="none"
                    android:scrollHorizontally="false"
                    android:textColor="#000000" />
            </LinearLayout>
    </ScrollView>

</TableRow>

can someone please help me how to display long text in textview ?

There are multiple ways of doing this. You can do this by using android:lines in your xml file. Your textview should not be able to go outside the boundaries of its parent. Follow this link and review some of the information on formatting http://developer.android.com/reference/android/widget/TextView.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM