I\'m trying to retrieve the height of a webview\'s content. it contains a html-string. The problem is that getContentHeight() returns always the same value (392), no matter
This issue has driven me nuts. Let me make a guess: Your content isn't loaded from the web or from the file system instead you make a call to WebView.loadData()
or WebView.loadDataWithBaseUrl()
(where you specify null
or an empty string in the latter case). Right?
If yes, then I guess I have a solution for you which was inspired by this discussion: Be sure to use the WebView.loadDataWithBaseUrl()
method and provide a baseUrl
which is not null
, not an empty string and is different for different content data. According to the SDK documentation the baseUrl
is only used to evaluate relative URLs inside the data (e.g. tags not specifying the domain name in their
src
attribute), so if your data does not reference external content I guess you can generate "virtual" URLs (haven't tried this).
It seems as if the WebView
is taking a look at the URL and if it doesn't change all subsequent calls to loadData...
will result in the same height of the WebView
.