Textview that doesn't show full text

≯℡__Kan透↙ 提交于 2019-12-14 01:22:20

问题


I'm creating a simple layout with a TableLayout and TableRow, that contain two TextViews. This is a part of code.

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

    <TableRow android:id="@+id/myTableRow">

    <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:padding="15dip"
        android:text="Short description"/>

    <TextView 
        android:id="@+id/textView1"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:padding="15dip"
        android:text="Large description"/>

    </TableRow>

The problem is that if there is long text in TextView1 then full text is not showing. How can I show full text in TextView1?


回答1:


Try out the update XML what have you given in question...may be this is what you wanted to do.

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <TableRow android:id="@+id/myTableRow" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="15dip"
            android:text="Short description" />

        <TextView
            android:id="@+id/textView1"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:padding="15dip"
            android:text="Large description" />
    </TableRow>

</TableLayout>



回答2:


to display multiple lines add :

android:ellipsize="none" //the text is not cut on textview width:

android:scrollHorizontally="false"   //the text wraps on as many lines as necessary: 


来源:https://stackoverflow.com/questions/21834285/textview-that-doesnt-show-full-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!