SysdataSpA / SDHtmlTextView

Inspired by HTMLTextView and enhanced with multiple CSS Style
Apache License 2.0
68 stars 27 forks source link

HTML tables rendering issue #10

Open ouachman opened 5 years ago

ouachman commented 5 years ago

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.

sranieri commented 5 years ago

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

ouachman commented 5 years ago

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?

sranieri commented 5 years ago

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

ouachman commented 5 years ago

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.

sranieri commented 5 years ago

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

ouachman commented 5 years ago

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 commented 5 years ago

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.