gpt4 book ai didi

Android: line-limited textview with "..."显示有更多内容

转载 作者:行者123 更新时间:2023-11-29 00:29:41 25 4
gpt4 key购买 nike

我在 TextView 中显示一个长的(随机的)文本。我想在此 TextView 中显示 3 行,如果有更多内容则显示点 (...)。我知道我可以使用 minLines 和 maxLines 限制 TextView 的行数,但我不知道在字符串中的何处添加点。

例如TextView 可能/应该看起来像

"This i random text
this is a short one
and more is here..."

"This one has a very
loooooooooooooooong
string so where ..."

最佳答案

您不需要知道在哪里添加点,TextView 可以为您完成。结帐android:ellipsize=end .请注意,椭圆大小的算法在旧的 android 版本中不能可靠地工作。 2.3、3 和 4+ 之间的确切行为可能存在差异。例如我知道它在 2.3 中不会显示超过两行

关于Android: line-limited textview with "..."显示有更多内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16629329/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com