Android Question Changing the content of an imageview depending the "position" of the text in a webview?

BlueVision

Active Member
Licensed User
Longtime User
Hi folks,
I want to create an internal help/advice-section within my app. Embedding pictures into the html itself is not preferred because of several reasons (zooming, picture quality, text to large picture scrolls out to early).
So I decided to put an imageview on the upper half of the display, below that a webview containing a larger html-file. So far so good. Is there a way to trigger an event to change the content of the imageview, depending on the position the webview is scrolled up/down to a several point? Because of the length of the text this is a better solution in my case than embedding the pictures into the text. Any solution for this?

Cheers, BV
 

JohnC

Expert
Licensed User
Longtime User
That seems like a complicated solution.

It sounds like you have control over the html inside the webview. If this is correct, then you could try this:

1) Force the size of all the images in the html to be thumbnail size (by specifying the size in the IMG tag) so they wont be too big.
2) Then assign a link to each image.
3) Catch the event of when the user clicks on an image (using the webview_OverrideUrl event)
4) Display the larger version of the clicked on image in the webview and allow it to be zoomed.

This way, since all the image sizes will be the same, the "look" of the main page will be consistent. And if the user wants to see a higher resolution of any image, they can simply click on it to view it. Then they can click the back key to return to the main HTML text.
 
Last edited:
Upvote 0

BlueVision

Active Member
Licensed User
Longtime User
Hi John,
thanks for the fast response.
You probably misunderstood. There is no control of the HTML-part during runtime.
It is much simpler, because I don't want to run into the issues you explained in your post above.
There is a webview containing only HTML-Text, linked into itself with hyperlinks for faster navigation within that HTML-file. This works fine.

Above the webview is an imageview. I want to change the content of that imageview depending on (this is an idea) the position of the scrollbar of the webview, so a corresponding picture can be loaded into the imageview. If I would do embedding of the pictures into HTML, the picture would scroll out to fast because there is not enough space on the display. What I am looking for is a triggering event depending on the position within the HTML-file forcing the loading of a different image into the imageview, so everything remains in context. The scrollbar-thing is only an idea, because the scrollbar indicates somehow more or less the "reading position" within that HTML. Tricky sideeffect: I probably can't use the scrollbar as indicator, because I want to hide the scrollbar- and zoom-controls of the webview...
 
Upvote 0

FrostCodes

Active Member
Licensed User
Hi folks,
I want to create an internal help/advice-section within my app. Embedding pictures into the html itself is not preferred because of several reasons (zooming, picture quality, text to large picture scrolls out to early).
So I decided to put an imageview on the upper half of the display, below that a webview containing a larger html-file. So far so good. Is there a way to trigger an event to change the content of the imageview, depending on the position the webview is scrolled up/down to a several point? Because of the length of the text this is a better solution in my case than embedding the pictures into the text. Any solution for this?

Cheers, BV

I advice you do it all inside the WebView but if you don't want to, you can use webviewExtras2 and use JavaScript to listen to the on scroll position and when you have reached your threshold you emit an event back to the b4a app and change the image inside the imageview.. this seems to be a stressful way to do what you want .. you can use html viewport to solve you responsive issue and just build it into you html page directly but any way you prefer go with it.
 
Upvote 0

BlueVision

Active Member
Licensed User
Longtime User
Thanks for responding...
That sounds really complicated. I am not that much into Java and all that stuff beside. Probably not worth doing that for a webview containing general advice and information the user is reading probably only once, if so...
 
Upvote 0
Top