Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果文本太长,我想缩短文本并在末尾添加“...”。这是我想剪辑文本的示例:
我尝试了多种代码变体(TruncateAt.END、.setLines(4)、...),但我认为这应该可行:
textv.setMaxLines(4); textv.setEllipsize(TruncateAt.MARQUEE);
但结果是这样的:
怎么了?
您可以获取字符串的子字符串,并将其用作最大长度,并在末尾添加 ...。
int MAX_LENGTH=40; if(inString.length > MAX_LENGTH) View.setText(inString.subString(0,MAX_LENGTH) + "...";
我希望这会帮助你...