Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML tables rendering issue #10

Open
ouachman opened this issue Jun 19, 2019 · 7 comments
Open

HTML tables rendering issue #10

ouachman opened this issue Jun 19, 2019 · 7 comments

Comments

@ouachman
Copy link

ouachman commented Jun 19, 2019

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
Copy link
Contributor

Hi, the issue has been fixed in this pull request #11 that will be merged soon.

@ouachman
Copy link
Author

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
Copy link
Contributor

sranieri commented Jun 20, 2019

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

@ouachman
Copy link
Author

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
Copy link
Contributor

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

@ouachman
Copy link
Author

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
Copy link
Author

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.

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

No branches or pull requests

2 participants