How to use custom ellipsis in Android TextView

前端 未结 5 1810
陌清茗
陌清茗 2020-12-31 09:55

I have a TextView with maxlines=3 and I would like to use my own ellipsis, instead of

\"Lore ipsum ...\"

I need

\"Lore ips         


        
5条回答
  •  鱼传尺愫
    2020-12-31 10:31

    I think the answer from @jmhostalet will degrade the performance (especially when dealing with lists and lots of TextViews) because the TextView draws the text more than once. I've created a custom TextView that solves this in the onMeasure() and therefore only draws the text once.

    I've originally posted my answer here: https://stackoverflow.com/a/52589927/1680301

    And here's the link to the repo: https://github.com/TheCodeYard/EllipsizedTextView

提交回复
热议问题