设置Textview最大长度,超出显示省略号
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#88000000"
android:layout_alignParentBottom="true">
<TextView
android:id="@+id/description_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="left"
android:maxEms="18"
android:maxLines="1"
android:ellipsize="end"
android:textColor="@android:color/white"/>
</RelativeLayout>
其中
android:maxEms="18"
android:maxLines="1"
android:ellipsize="end"
很关键
本文介绍如何在Android中设置TextView的最大长度,并当文本超出指定长度时显示省略号。通过使用XML属性android:maxEms、android:maxLines及android:ellipsize实现单行文本的截断效果。
4636

被折叠的 条评论
为什么被折叠?



