I am implementing an WebView such that it can resize its height according to the content height. I tried to do the following:
WebView view = new WebView(context);
view.loadData(htmlString, "text/html", "utf-8");
view.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
Log.d("2", view.getContentheight() + "");
// Set the height of the webview to view.getContentHeight() here?
}
});
Log.d("1", view.getContentHeight() + "");
Where htmlString is a String of HTML format.
However both the two Logs return 0.
I am not sure if I am doing the right thing. How can I know the content height then set the height of the WebView accordingly?