EllipsizedTextView icon indicating copy to clipboard operation
EllipsizedTextView copied to clipboard

Not working 100%

Open slott opened this issue 7 years ago • 5 comments

I'm getting mixed results when using this. I've put in

    android:ellipsize="end"
    app:ellipsis="@string/more"

and I see text ending in with "..." or "more".

Haven't looked at your code just yet - but something funny is going on there. The places where it just renders "..." it looks like you haven't calculated enough space to render the provided ellipsis string.

slott avatar Oct 02 '18 12:10 slott

Hi @slott, thanks for the feedback. That's strange indeed. Have you noticed if it happens in ListViews/RecyclerViews only, perhaps? If you could somehow help me reproduce it, I'd appreciate it.

gsavvid avatar Nov 28 '18 09:11 gsavvid

Hi @gsavvid , I think your code will not working when the long text has character "\n".

anh-lt avatar Jan 02 '19 08:01 anh-lt

the long text has character "\n

How to solve?

7-cat avatar Sep 14 '19 15:09 7-cat

To fix it I've use this extension function, to remove break lines.

private fun String.toNonBreakableString() =
        this.trim().replace(" ", "\u00A0")

Plus I've changed the calculate where the ellipsis was being removed in each line. So instead do :

availableTextWidth = (availableScreenWidth - paint.measureText(ellipsis)) * maxLines 

Now I'm doing:

availableTextWidth = (availableScreenWidth - * maxLines ) - paint.measureText(ellipsis) 

So now it just removes the space in the end.

alacanna avatar Feb 10 '21 15:02 alacanna

@alacanna Thank you very much for this. Would you mind opening a pull request with the suggested changes?

gsavvid avatar Feb 11 '21 10:02 gsavvid