我在 android xml 文件中使用android:ellipsize="end",令人惊讶的是我没有得到我想要的布局,显示了 3 个点(...),但在那个点之后还有另一个词被截断。这也是一个“不总是”的行为,检查附加的 ListView,有时,行为是正常的,有时不是。
这是我设备上的布局截图,
我不知道为什么会这样。这是我的 xml 文件,tv_news_content TextView 有问题-
<?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="100dp"
android:background="@color/white" >
<ImageView
android:id="@+id/iv_next_tier"
android:layout_width="18dp"
android:layout_height="21dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:src="@drawable/right_arrow" >
</ImageView>
<TextView
android:id="@+id/tv_news_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="7dp"
android:layout_marginRight="5dp"
android:layout_marginTop="3dp"
android:layout_toLeftOf="@+id/iv_next_tier"
android:ellipsize="end"
android:maxLines="2"
android:text="News Title"
android:textColor="@color/black"
android:textSize="17dp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_news_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/tv_news_title"
android:layout_below="@+id/tv_news_title"
android:layout_marginRight="5dp"
android:layout_toLeftOf="@+id/iv_next_tier"
android:ellipsize="end"
android:maxLines="2"
android:text="News Contents"
android:textColor="@color/black_light"
android:textSize="15dp" />
<View
android:id="@+id/view"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_below="@+id/tv_news_content"
android:layout_marginTop="5dp" />
为了清楚起见,tv_news_title是最上面的粗体 TextView,而 iv_next_tier是右边的小箭头型 ImageView。& tv_news_content是我面临的问题的 TextView。
为什么我没有得到想要的输出的任何解决方案?所需的输出意味着始终正常的行为 - 我希望在tv_news_content TextView的第二行末尾的这 3 个点,而不是在截断的单词之前。
任何建议表示赞赏。