2010-11-15 50 views
4

我有一個小的裁剪問題,我無法使用TableRow中的EditText視圖來解決。無論我嘗試什麼,EditText視圖都會被剪輯(附加屏幕截圖),或者,如果將shrinkColumns設置爲0或1,則標籤文本消失(並且EditText視圖佔用整個寬度)。佈局如下:在TableLayout中使用EditView處理Android文本裁剪問題

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" android:layout_height="fill_parent" 
android:orientation="vertical" android:padding="10dip"> 

    <TableLayout android:orientation="vertical" 
    android:layout_width="fill_parent" android:layout_height="fill_parent"> 

    <TableRow android:orientation="horizontal" 
    android:layout_width="fill_parent" android:layout_height="wrap_content"> 

     <TextView android:paddingRight="10dip" android:layout_column="1" 
     android:text="Label Text" /> 
     <EditText android:text="Very long text that makes the text view go on clipping frenzy" 
     android:layout_width="wrap_content" android:layout_height="wrap_content" /> 

    </TableRow> 

    </TableLayout> 

</LinearLayout> 

我試過它在QVGA和HVGA,一個的HTC Hero上2.1和野火2.1上運行,以及一個2.2模擬器。我也玩過clipToPadding屬性,這在我的情況下似乎沒有幫助。如果我使用長文本設置提示屬性並將文本值留空,則會出現同樣的問題。

由於我沒有做任何特別複雜的事情,我懷疑我身邊有一個簡單的錯誤。任何想法,提示或建議都受到高度讚賞。

乾杯!

alt text

+0

你應該先嚐試接受一些答案,這對你有好處有快速回答 – 2010-11-15 12:13:46

回答

7

設置機器人:shrinkColumns =您TableLayout 「1」,並刪除機器人:layout_column = 「1」 TextView的。

+0

謝謝!這工作完美。我最終使用setColumnShrinkable(1,true)來避免縮小標籤。 – 2010-11-16 07:39:48

1

添加機器人:layout_weight =「1」,你的EditText,花了一段時間來解決這個問題..........

但不知道它的原因... ....