2010-11-15 56 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,花了一段时间来解决这个问题..........

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