[Android] TextView只显示一行,多余显示省略号...

Android Textview 只显示一行,多余部分显示"…"

<TextView
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:singleLine="true"
android:ellipsize="end"/>

android:ellipsize="end"

在TextView 和 EditText中,可以使用ellipsize来设置文字溢出隐藏,如:“一段很长的文本…”

用法如下:

在xml中

android:ellipsize = "end"   省略号在结尾
android:ellipsize = "start"   省略号在开头
android:ellipsize = "middle" 省略号在中间
android:ellipsize = "marquee" 跑马灯

配合maxLines使用,经测试配合maxLength使用无效

 <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ellipsize="end"
            android:maxLength="18" />

你可能感兴趣的:(Android)