Not working 100%
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.
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.
Hi @gsavvid , I think your code will not working when the long text has character "\n".
the long text has character "\n
How to solve?
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 Thank you very much for this. Would you mind opening a pull request with the suggested changes?