我试图在具有多行文本的文本视图末尾添加一个省略号。“...”正在显示,但它位于文本的最后一个空格,并且是其他字符,后面是其他字符。如何确保“...”始终位于末尾。
查看示例图片
XML 布局文件是:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="5dp"
android:orientation="horizontal" >
<TextView
android:id="@+id/nfDateMonth"
android:layout_width="64dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="8dp"
android:layout_marginTop="2dp"
android:background="@drawable/topsegment"
android:gravity="center"
android:text="APR"
android:textAllCaps="true"
android:textColor="#f2e606"
android:textSize="22sp"
android:textStyle="bold" />
<TextView
android:id="@+id/nfDateDate"
android:layout_width="64dp"
android:layout_height="wrap_content"
android:layout_below="@+id/nfDateMonth"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="8dp"
android:background="@drawable/bottomsegment"
android:gravity="center"
android:text="28"
android:textSize="22sp" />
<TextView
android:id="@+id/nfTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:layout_marginTop="0dp"
android:layout_toRightOf="@+id/nfDateMonth"
android:text="Half Marathon"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="16sp" />
<TextView
android:id="@+id/nfContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/nfTitle"
android:layout_gravity="left"
android:layout_marginBottom="2dp"
android:layout_marginRight="16dp"
android:layout_marginTop="2dp"
android:layout_toRightOf="@+id/nfDateDate"
android:ellipsize="end"
android:maxLines="2"
android:text="Content\nline two line three sadsa dsd dsa dsd big big big sd sad sad sadsadsad asd sad as d asd as das das das das da sd asd asd one two three four five sixx seven"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="12sp" />
</RelativeLayout>