2014-02-17 47 views
3

我用TableLayout和TableRow創建了一個包含兩個TextView的簡單佈局。這是代碼的一部分。不顯示全文的Textview

<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> 

問題是,如果在TextView1中有長文本,則不顯示全文。我如何在TextView1中顯示全文?

+0

你想顯示文本的多行和換行? –

+0

如果文本很長,是的,我想顯示多行 – user3289078

+2

然後看到http://stackoverflow.com/questions/4851659/how-to-wrap-text-in-textview-in-android –

回答

3

嘗試更新XML你給出了什麼問題...可能是這是你想要做的。

<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

顯示多行補充:

android:ellipsize="none" //文本不削減TextView的寬度:

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