我在我的TableLayout的列中有一個TextView。如果TextView的文本長度大於列可以容納的長度,我希望TextView截斷和橢圓化,但它只是拉伸列並破壞我的佈局。沒有任何關於TextView截斷的建議我找到了,我假設這是由於表。有什麼建議麼?Android:如何截斷TableLayout中的TextView?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/label"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</TextView>
<RelativeLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/Icon"
android:src="@drawable/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageView>
<TextView
android:id="@+id/Value"
android:layout_toRightOf="@id/Icon"
android:text="very long stringvery long stringvery long stringvery long stringvery long stringvery long stringvery long stringvery long stringvery long stringvery long stringvery long stringvery long stringvery long stringvery long stringvery long stringvery long string"
android:inputType="text"
android:maxLines="1"
android:ellipsize="end"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
</RelativeLayout>
*編輯:代碼表:
int fiveDip = convToDip(5, getContext());
Table table = new TableLayout(getContext());
table.setPadding(fiveDip, fiveDip, fiveDip, fiveDip);
table .setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT, TableLayout.LayoutParams.FILL_PARENT));
你能提供您TableLayout XML? – Joe 2011-04-20 19:02:11
@Joe。我在代碼中定義它,我將代碼添加爲我的問題的編輯。 – ab11 2011-04-20 19:08:04