android:TextView单行显示设定字符长度,超过后面为省略号
16lz
2021-01-23
在 TextView 中加入:
(注意:layout_width="wrap_content",宽度必须是wrap_content,为match_parent无效)
android:maxEms="10" //限制字节长度为10
android:ellipsize="end" //省略号在最后面
android:singleLine="true" //超过长度10为省略号
即可;如:
android:textSize="18dp" android:text="计费的手机看撒即可杰卡斯发送到" android:padding="20dp" android:singleLine="true" android:maxEms="10" android:ellipsize="end" android:layout_width="wrap_content" android:layout_height="wrap_content" />
下面的方法是 TextView 字数很长,显示不下的让它后面自动为省略号:
android:maxWidth="140dp"
android:ellipsize="end"
android:singleLine="true"
重要的是 android:maxWidth="140dp" 指定长度,超过长度后面自动为省略号。
更多相关文章
- android中的字符长度
- Android中计算textView长度问题
- android Toast的时间长度
- android 计算字符串长度,高度
- Android——控制edittext输入字符长度,中文占2个,英文占1个
- android edittext 输入长度限制并提示
- Android中TextView内容过长加省略号,设置超出6个字就用省略号表示
- android文本限制输入行数,多余部分显示省略号