Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the ellipsis string of Android TextView?(... to ...more)

I want to change the ellipsis string from ... to custom string, such as ...[more]. But in TextUtil, the ellipsis string is fixed:

private static final String ELLIPSIS_STRING = new String(ELLIPSIS_NORMAL);

Then how to change the ellipses?

like image 696
Neo lee Avatar asked Oct 28 '25 09:10

Neo lee


1 Answers

I was surprised that there isn't any good solution to that yet, so I spent sometime and wrote my own custom TextView which allows you to show a custom ellipsis. Few things I had in mind while developing it:

  1. The TextView shouldn't draw the text more than once since this is a heavy operation and could compromise the performance.
  2. It should respect Spanned strings.
  3. Support custom text color for the ellipsis.

Have a look and let me know if you find any issues: https://github.com/TheCodeYard/EllipsizedTextView

And here's a screenshot:

enter image description here

like image 187
Georgios Avatar answered Oct 31 '25 00:10

Georgios