Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

HTML.fromHtml adds space at end of text #19

Closed
benju69 opened this issue Sep 21, 2015 · 6 comments
Closed

HTML.fromHtml adds space at end of text #19

benju69 opened this issue Sep 21, 2015 · 6 comments
Labels

Comments

@benju69
Copy link

benju69 commented Sep 21, 2015

Html.fromHtml adds extra lines after the text. Html class looks at a

tag, and append two "\n" chars to the end.

see : http://stackoverflow.com/questions/11882323/html-fromhtml-adds-space-at-end-of-text

@dschuermann
Copy link
Member

What is you suggestion to do here?

@dschuermann dschuermann added the bug label Dec 3, 2015
@Mathbl
Copy link

Mathbl commented Dec 4, 2015

I think that simply trimming the string before doing setText would do the trick there (like explained in the SO link above).

@dschuermann
Copy link
Member

This sounds like a good solution: http://stackoverflow.com/a/10187511

@dr03lf
Copy link

dr03lf commented Dec 27, 2015

The following is working for me:

commentView.setHtmlFromString(comment.bodyHtml, HtmlTextView.RemoteImageGetter())
commentView.text = trimTrailingWhiteSpace(commentView.text)

fun trimTrailingWhiteSpace(source: CharSequence): CharSequence {
        var i  = source.length
        while(--i >= 0 && source.get(i) == '\n'){}
        return source.subSequence(0, i + 1)
}

@dschuermann
Copy link
Member

I am open for pull requests to fix this.

@dschuermann
Copy link
Member

fixed in #37

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants