关于textview 限制字数末尾加省略号的解决办法

正确代码如下:
<TextView
    android:id="@+id/tv_signTxt"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_marginRight="@dimen/dp_10"
    android:layout_toLeftOf="@+id/iv_sign_right"
    android:ellipsize="end"
    android:maxEms="12"
    android:singleLine="true"
    android:text="随风随风时间如水,人情冷漠哈哈唯我独醒嗯嗯"
    android:textColor="@color/title_text_color2" />

很简单的需求,一开始上来我就写了maxlength=12 maxline=1 ,android:ellipsize="end"就是不出现省略号,长度限制成功,后来看了看textview的api改了改成了,具体哪些区别自己去百度啊。

猜你喜欢

转载自blog.csdn.net/Zhao_Yanqing/article/details/88691611