我在我的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