[英]Android question about TableLayout and ellipsis
我的TableLayout出現問題。 它由兩列和多行組成。 當第二列的TextView包含較長寬度的文本時,它將把該列(下一行)中的TextView移出屏幕(向右)。 相反,我希望它將文本保留在左側,並在其末尾加一個省略號。 誰能看到我的XML出了什么問題?
<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>
根據要設置上限的列,您需要使用
android:shrinkColumns=x
在您的TableLayout
,其中x是您要橢圓化的列的索引。
您可能還希望將TextView
上的maxLines也設置為1。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.