2
我遇到了TableLayout问题。它由两列和多行组成。当第二列的TextView包含更长宽度的文本时,它会将该列中的TextView(在下面的行中)推离屏幕(向右)。相反,我希望它将文本保留在左侧,并使用省略号来限制文本的末尾。任何人都可以看到我的XML有什么问题吗?有关TableLayout和省略号的Android问题
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#4096cc" >
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/roundedshape"
android:layout_margin="5dp"
android:stretchColumns="1">
<TableRow>
<TextView
android:layout_column="1"
android:text="Server Name"
android:textStyle="bold"
android:padding="10dip" />
<TextView
android:id="@+id/txtServerName"
android:text=""
android:gravity="right"
android:ellipsize="end"
android:padding="10dip" />
</TableRow>
<View
android:layout_height="2dip"
android:background="#FF909090" />
<TableRow>
<TextView
android:layout_column="1"
android:text="Status"
android:textStyle="bold"
android:padding="10dip" />
<ImageView
android:id="@+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:padding="10dip"
android:src="@drawable/icon" />
</TableRow>
.
.
.
</TableLayout>
</LinearLayout>
感谢您的帮助,我不知道shrinkColumns。然而,我尝试过,由于某种原因,它使得该行的高度很高,并且整个屏幕的宽度也是第二列......我根本看不到第一列。第二列中的文本也没有用省略号进行限制。有任何想法吗? – littleK 2011-06-17 04:03:23
2是您的布局的正确值。您要缩小的那些TextViews列位于第二索引(第三)列中。您通过将layout_column设置为1来开始第二列。这也是一个零索引属性。 – 2011-06-17 04:14:35
好吧,我做了一个小小的调整,并使用了android:stretchColumns =“1” 和android:shrinkColumns =“2”,并且一切看起来不错。感谢您的帮助! – littleK 2011-06-17 04:16:47