Android Question HTML interpretation

Stefano Di Chiano

Active Member
Licensed User
I'm helping my father with an app he made for his customer.
On the main module, I have a few buttons that set a string with an url and then call another module. Here's an example of the click event of the buttons:

buttons click:
Main.nomePagina = "https://example/page.htm"
StartActivity(examplemodule)

On the other module, there is simply a webview on which it is loaded the url set on the global string. The html page loaded only contains an image and some formatted text.

Some users reported a problem with the text format displayed on the webview. This doesn't happen on every device though, it has been reported a bad formatting of the text on a Samsung Note 10.

I think it could be the browser, the device or the ".htm" extension of the url, but I don't know if I'm right and what could be the solution in case I am.

Does someone know how to solve this kind of issue?

Thanks.
 

JohnC

Expert
Licensed User
Longtime User
See Tip #1 in my below signature about adding the ChromeClient to Webview for better performace:
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
unless you know how to format a webpage (or unless the page has very little formatting), there will be differences in display. you need to learn how to format a webpage and you need devices to test with. in the case of a note 10, you have to get one or get a screen capture of what it looks like. but that only addresses the note 10. other devices may show other issues. if your code (html and/or javascript) makes assumptions about where the page will be displayed, you're asking for problems. eg, if you hardcode things like "width=100px", 100 pixels looks different on different devices. hard-coded image sizes will look different on different screen sizes. that could easily force text to display on top of itself.

if you don't have the resources for test devices, you'll need to work with screen captures and see if you can figure out how you're causing the text to display incorrectly.

by the way, showing and image and some text in a webview, isn't the only way to handle this. you could do it in b4a with, eg, a formatted label. there is still the issue of different devices with different screen sizes, but questions regarding uniformity across devices have been asked here many times. plenty of links in the forum for you to hunt through.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
On the other module, there is simply a webview on which it is loaded the url set on the global string. The html page loaded only contains an image and some formatted text.

Did you create the HTML page that is being displayed at the URL of the webview, or is the page at the URL from a third-party that you have no control over it's contents?
 
Upvote 0

Stefano Di Chiano

Active Member
Licensed User
Did you create the HTML page that is being displayed at the URL of the webview, or is the page at the URL from a third-party that you have no control over it's contents?
I didn't make the app. I'm helping solve the problem that showed up. For what I know, they made all the html pages with an editor, they didn't write the code. Then they put this pages on a domain they own. The webView load them by the url.
 
Upvote 0

Stefano Di Chiano

Active Member
Licensed User
As an alternative to html pages, I'm trying to write the text on a label that I put on the panel of a scrollView later. There are 2 things that I can't do though:
1 - justify alignment. I looked in the forum but I couldn't find a solution that provides a justified alignment.
2 - format the text. For example I need to make a line bigger and bold for the title. But since I'm setting the label text attribute, I don't know how to do this.

If there are solutions to these 2 points, I wouldn't need html anymore so I could work around the initial problem.
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Since you can contact the people who can modify the pages that are not displaying properly, the best thing is to get them to "fix" their pages.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Example where html is parsed and displayed with BCTextEngine: https://www.b4x.com/android/forum/t...leroma-mastodon-client-step-1.119426/#content
It is a bit complicated example as it also does many other things.

i_view64_FAQWSjENvw.png
 
Upvote 0
Top