Android Question Detecting the height of a Webviews content

Kevin Hartin

Active Member
Licensed User
I was looking through the 16 or so pages on the WebView thread and couldn't figure out how to determine the height of the content rather than the webview objects height.

There was a reference to "possibly" using a page down operation to determine when you are at the end, but this will not work for me.

I want to put a Page up and/or page down icon in front of the webview if it has content outside the viewport, rather than rely on the user to try and scroll it. Any ideas?

Alternatively, is there a way to supress the auto hide of the vertical scrollbar?

Thanks,
Kev
 

drgottjr

Expert
Licensed User
Longtime User
i don't think you can know the height of its "content". its physical height is one thing;
what's actually visible at any given time on any given device might not be knowable.
or at least not controllable by you. (technically, you could capture the screen and see
exactly what the user sees, but that's not going to be of any use to you.)

i think you have to approach it from a different angle, i.e., the way a pdf document
does with discrete "pages" whose content is controlled by you. that way, when the
user taps "page down", a knowable page is produced. whether that actually works
on a webview is unclear. in any case, i think you have to generate content that is
guaranteed to fit in a webview viewport. then create pages that can be called as
the user taps the up/down button. you're doing it the other way 'round, ie, starting
with all the content and trying to divide it up into virtual pages (which may or may
not exist). at least that's how it strikes me.

i don't understand what you mean by a webview's "auto hide" scrollbars. as
far as i am aware, they are "auto visible" unless you manually hide them, which can
easily be done.
 
Upvote 0

Ivica Golubovic

Active Member
Licensed User
I was looking through the 16 or so pages on the WebView thread and couldn't figure out how to determine the height of the content rather than the webview objects height.
Example:
Dim jo As JavaObject = WebView1
Dim ContentHeight As Int = jo.RunMethod("getContentHeight",Null) 'Result in pixels

Alternatively, is there a way to supress the auto hide of the vertical scrollbar?
Example::
Dim jo As JavaObject = WebView1
jo.RunMethod("setVerticalScrollBarEnabled",Array(True))
jo.RunMethod("setScrollbarFadingEnabled",Array(False))
 
Upvote 0

Kevin Hartin

Active Member
Licensed User
Example:
Dim jo As JavaObject = WebView1
Dim ContentHeight As Int = jo.RunMethod("getContentHeight",Null) 'Result in pixels


Example::
Dim jo As JavaObject = WebView1
jo.RunMethod("setVerticalScrollBarEnabled",Array(True))
jo.RunMethod("setScrollbarFadingEnabled",Array(False))
Thanks,

The getContentHeight only returns a Zero, but the scrollBar code works. At least now my scroll bars stay visible if they need to.

Kev
 
Upvote 0
Top