当我使用TextView
and singleLine="true"
(ellipsize="end"
我的顶级TextView)时,
它运行良好
但在另一个 TextView
有超过 1 行的情况下(在我的情况下,我的底部有 3 行TextView
),
lines="3" and maxLines="3" and ellipsize="end",
无法正常工作。
当我不ellipsize="end"
输入 tvDesc 时,它显示 3 行,没关系。这是代码:XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/imgv"
android:layout_width="65dp"
android:layout_height="80dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/img1"
android:scaleType="fitXY" />
<TextView
android:id="@+id/tvTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/imgv"
android:background="@android:color/white"
android:textColor="@android:color/black"
android:text="Title testing line number and ellipsize at end"
android:maxLines="1"
android:singleLine="true"
android:ellipsize="end" <--- WORKS WELL
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/tvDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tvTitle"
android:layout_toRightOf="@+id/imgv"
android:layout_alignBottom="@+id/imgv"
android:layout_alignParentRight="true"
android:textSize="14dp"
android:lines="3"
android:maxLines="3"
<---------- WITHOUT ellipsize
android:text="I wanna this textview of having 3 lines and ellipsize at END and at this time I am Testing for it. This TextView shows 3 lines WITHOUT ellipsize property, but shows only 2 Lines when ELLIPSIZE property is setted"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
上面的代码显示了具有 3 行和无椭圆大小的 TextView tvDesc。这是图片:
但是,我想省略,所以我使用以下代码:XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/imgv"
android:layout_width="65dp"
android:layout_height="80dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/img1"
android:scaleType="fitXY" />
<TextView
android:id="@+id/tvTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/imgv"
android:background="@android:color/white"
android:textColor="@android:color/black"
android:text="Title testing line number and ellipsize at end"
android:maxLines="1"
android:singleLine="true"
android:ellipsize="end"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/tvDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tvTitle"
android:layout_toRightOf="@+id/imgv"
android:layout_alignBottom="@+id/imgv"
android:layout_alignParentRight="true"
android:textSize="14dp"
android:lines="3"
android:maxLines="3"
android:ellipsize="end" <------ WITH ELLIPSIZE
android:text="I wanna this textview of having 3 lines and ellipsize at END and at this time I am Testing for it. This TextView shows 3 lines WITHOUT ellipsize property, but shows only 2 Lines when ELLIPSIZE property is setted"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
其中显示 TextView tvDesc 只有 2 行和 Ellipsize,
这不是正确的用户界面,如下所示:
我想在 TextView tvDesc 中使用 ellipsize 3 行
谁能帮我。?