Android Question What means .GetContentHeight from the WebviewExtras and WebViewExtras2 library

Walter Brunmueller

Member
Licensed User
Hello!

I receive unexpected Values from GetContentHeight

<html>
<head></head>
<body>
Bitte
</body>
</html>
WebView: Top: 89 Left: 0 Width: 918 Height: 35
<html>
<head></head>
<body>
Nochmal
</body>
</html>
WebView: Top: 89 Left: 0 Width: 918 Height: 35
<html>
<head></head>
<body>
Ok
</body>
</html>
WebView: Top: 89 Left: 0 Width: 918 Height: 35
<html>
<head></head>
<body>
Wie ist der Status
<br>Habt ihr schon was rausgefunden?
</body>
</html>
WebView: Top: 89 Left: 0 Width: 918 Height: 184
<html>
<head></head>
<body>
Nochmal
</body>
</html>
WebView: Top: 89 Left: 0 Width: 918 Height: 35
<html>
<head></head>
<body>
Nun vom Handy
</body>
</html>
WebView: Top: 89 Left: 0 Width: 918 Height: 72
<html>
<head></head>
<body>
Neue Info
</body>
</html>
WebView: Top: 89 Left: 0 Width: 918 Height: 54
<html>
<head></head>
<body>
Heute wieder ein Eintrag
</body>
</html>
WebView: Top: 89 Left: 0 Width: 918 Height: 91
<html>
<head></head>
<body>
Eskalation
</body>
</html>
WebView: Top: 89 Left: 0 Width: 918 Height: 35
<html>
<head></head>
<body>
Send a Test
</body>
</html>
WebView: Top: 89 Left: 0 Width: 918 Height: 72

On the screen it looks like this

Screenshot_20200722-070705.jpg


You can see, that there are most of the bodies are only one Line.
But the calculated Height is very different (form 35 to 91)
It looks like that it depends on the Length of the text!?

What can be the reason for this?

Thank you for your help
 

Walter Brunmueller

Member
Licensed User
Thank you for your fast reply!

Why changes the ContenHeight if the body is shown only in one line?
In my examlple I get different Height for 'one-line' bodies?

With ' It looks like that it depends on the Length of the text!? ' I thought the length of the text in one line.

Thanks
 
Upvote 0

DonManfred

Expert
Licensed User
Not true. The html in the screenshot have multiple lines. one with emailadres, one with text.
Other parts of your screen shows multiple answerline which, for sure, results in a higher contentheight.

The less you use webview the better.

If you want to use webview i suggest to learn how a webview is build from the html showing (and how html works), define a stylesheet with much less spcacing.
 
Upvote 0

Walter Brunmueller

Member
Licensed User
Sorry, I forgot to say, that in the screenshot
you see a label (email-adress) an a webview (the text which is cut off sometimes because the height is too small)

I the webview ther shoul be only the html-text which is I appen on the to of the post.
There you can see the log from the html-text then the log of the webview-size.
Then again the log from the html-text then the log of the webview-size.

<html>
<head></head>
<body>
Nochmal
</body>
</html>
WebView: Top: 89 Left: 0 Width: 918 Height: 35
<html>
<head></head>
<body>
Nun vom Handy
</body>
</html>
WebView: Top: 89 Left: 0 Width: 918 Height: 72

And so you can see, that there are many 'one-line' html-bodies where the ContenHeight is very different.
In this example we get Height 35 for 'Nochmal' and Height 72 for 'Nun vom Handy'.
Why?

I have to use webview, because this text I get out of a JSON string from a web-server.

Thanks for your patience
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Do you have an idea why I get different Heights?
When I started to develop the Pleroma client, my first decision was to avoid using WebView as I knew that it will be difficult to create such a list with many WebViews, and it will be difficult to properly measure each item. Especially if you are interested in a cross platform solution.
This is why I chose to use BCTextEngine for the rich text. This is not a simple replacement to WebView but it does give you more control.
 
Upvote 0
Top