SDHtmlTextView icon indicating copy to clipboard operation
SDHtmlTextView copied to clipboard

HTML tables rendering issue

Open ouachman opened this issue 5 years ago • 7 comments

Hello,

HTML tables do not seem to be correctly rendered. I see 2 major issues when you have more than 1 line:

  1. A space is added between each row
  2. The last row is repeated. Let's say you have 6 rows in your table, you will see 6 rows, but the last row will be repeated multiple times, replacing the rows that should be displayed.

There is also an issue where table header is not centered horizontally.

In the screenshot below, you will see 3 components in that order: a webview, a textview using the native HTML.fromHtml method, a text view using htmlSpanner.

Capture d’écran 2019-06-19 à 14 55 15

Otherwise the library works great, but without tables support unfortunately webview is the only alternative and it's not as fast and lightweight as a TextView.

ouachman avatar Jun 19 '19 12:06 ouachman

Hi, the issue has been fixed in this pull request https://github.com/SysdataSpA/SDHtmlTextView/pull/11 that will be merged soon.

sranieri avatar Jun 20 '19 09:06 sranieri

Great :) I will let you know how that works out for me. Thanks a lot for the quick fix.

On a side note, how do I get the latest build from Gradle as I don't see any release on this page? So far I have been using the instructions on this page: https://android-arsenal.com/details/1/6563#!package

Is there a better way?

ouachman avatar Jun 20 '19 09:06 ouachman

Just check the readme section https://github.com/SysdataSpA/SDHtmlTextView#usage dedicated to usage and installation

sranieri avatar Jun 20 '19 10:06 sranieri

Thank you. Problem solved.

As for the additional lines and space at the bottom, I simply removed both the "builder.append("\n");" in the TableHandler.handleTagNode method and they are gone. I have the same issue with lists, I guess it can be resolved the same way.

ouachman avatar Jun 20 '19 11:06 ouachman

With the lists I don't see any issue in my sample app. Can you give me more info about that?

sranieri avatar Jun 20 '19 12:06 sranieri

Here are 2 screenshots. One for tables, one for lists. On each screenshot you have a webview, a textview using the native Html.fromHtml method and a textview using this library.

HTML code: <table border="1" style="border-collapse: collapse"><th colspan="5">Header</th></tr></thead><tbody><tr><td>A1</td><td>A2</td><td>A3</td><td>A4</td><td>A5</td></tr><tr><td>B1</td><td>B2</td><td>B3</td><td>B4</td><td>B5</td></tr></tbody></table> Capture d’écran 2019-06-20 à 16 43 05

HTML code: <ul style="margin-bottom:0;"><li>item 1</li><li>item 2</li><li>item 3</li></ul>

Capture d’écran 2019-06-20 à 16 43 35

ouachman avatar Jun 20 '19 14:06 ouachman

Hello @sranieri. An issue I encountered with your fix is that if you reuse the htmlspanner for multiple values, the first row will always be centered if it has ever been once. To fix this I added "hasHeader = false;" at the beginning of the handleTagNode method in TableHander.

ouachman avatar Jun 21 '19 10:06 ouachman