Setting Ellipsize on TextView reduces lines shown by one (instead of only ellipsizing last)

前端 未结 6 605
慢半拍i
慢半拍i 2020-12-12 16:29

when I am using TextView with singleLine="true" and ellipsize="end"(my top TextView), it works well

<
6条回答
  •  长情又很酷
    2020-12-12 17:11

    Try it

    tv.setSingleLine(false);
    tv.setEllipsize(TextUtils.TruncateAt.END);
    int n = 3; // the exact number of lines you want to display
    tv.setLines(n);
    

    refer Programmatically create TextView with ellipsis

提交回复
热议问题